How to sort a range

rcorre via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Mar 9 04:21:55 PST 2016


On Wednesday, 9 March 2016 at 09:15:01 UTC, Edwin van Leeuwen 
wrote:
>
> I'm not sure why your fix didn't work, but generally I work 
> around this by converting the OnlyResult into an array:
>
> import std.array : array;
> assert(only(3,1,2).array.sort.equal(only(1,2,3)));

I'd like to avoid allocating here.

>
>
> If you are looking for a lazy uniq that works on non sorted 
> ranges, I implemented one not to long ago:
> http://github.com/BlackEdder/ggplotd/blob/master/source/ggplotd/range.d

That sounds like the kind of thing I was looking for. I'll take a 
look, thanks!



More information about the Digitalmars-d-learn mailing list