custom sorting of lists ?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sun Oct 14 01:31:26 UTC 2018


On Saturday, October 13, 2018 6:52:05 PM MDT Steven Schveighoffer via 
Digitalmars-d-learn wrote:
> You can't quick-sort a list. You can merge sort it, and it's O(nlgn).
>
> I'll work on getting a sort routine into Phobos for it, but I don't know
> what the appropriate location for it is, as a member or along-side
> std.algorithm.sort.

Unless there's something about the implementation that's tied to the list
itself, I would think that it would make more sense to make it a generic
algorithm, then it will work with any non-random-access range, and it avoids
needing to reimplement it for similar circumstances. IMHO, it really only
makes sense to tie it to the container if the implementation itself needs to
be for some reason.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list