[Issue 5076] std.algorithm.sorted / schwartzSorted

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 20 08:50:30 PDT 2010


http://d.puremagic.com/issues/show_bug.cgi?id=5076



--- Comment #9 from Peter Alexander <peter.alexander.au at gmail.com> 2010-10-20 08:49:43 PDT ---
(In reply to comment #8)
> See another case:
> http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.learn&article_id=22381
> This is supposed to not work:
> sort(map(...))
> This is supposed to work:
> sorted(map(...))

Just implement sorted et al. something like this:

auto sorted(Output = ElementType!InputRange[], InputRange)(InputRange range)
{
  Output output = Output(range); // copy range into new container
  sort(output);
  return output;
}

I don't know if you can construct built-in arrays like that, but you should,
and you can always specialise for it if necessary.

This allows the input range to be whatever it likes (including Map), and also
gives you the choice of the output range.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list