Lazy sort

via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Sep 11 07:11:45 PDT 2015


On Friday, 11 September 2015 at 12:23:52 UTC, ixid wrote:
> Yes, I was reading about heapsort. I was only thinking about 
> the usability POV (I mean isn't reduced pretty much an eager 
> operation that accepts a lazy input? Why can't sort do that?) 
> but it could also offer some performance improvement if you 
> only use a part of the sorted array.

I think there is something called "partial sort" in Phobos, but 
"lazy" sorting is the same as a priority queue.

You need to look at all elements before finding the largest one, 
that's why you cannot turn sort into a plain generator (or lazy 
range as some may call it).



More information about the Digitalmars-d-learn mailing list