Functional Sort

"Nordlöw" via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Nov 15 06:34:05 PST 2014


On Saturday, 15 November 2014 at 08:52:45 UTC, Meta wrote:
> On Saturday, 15 November 2014 at 03:47:25 UTC, Steven 
> Schveighoffer wrote:
>> err... this isn't what you want. That will sort the range, and 
>> then make a copy of the sorted range as an array.
>
> Yes, I didn't see the the second constraint to not sort the 
> original range.
>
> Sort before .array -> original will be sorted.
>
> Sort after  .array -> original will not be sorted.

BTW: When I uncomment line

     /* assert(x.sorted == y); */

in string unittest it errors as

sort_ex.d(160,5): Error: can only sort a mutable array
sort_ex.d(178,13): Error: template instance sort_ex.sorted!string 
error instantiating

What's wrong with my isArray-overload of sorted?


More information about the Digitalmars-d-learn mailing list