https://issues.dlang.org/show_bug.cgi?id=14340

--- Comment #6 from Xinok <[email protected]> ---
Gah, sorry, I misunderstood the problem. >_<  For some reason, I thought your
predicate was dependent on the order of the elements. Ignore my last post...

I still feel that this is bad practice and should be discouraged in general.
The simpler solution would be to dup' the range and refer to that, in which
case you could have a strongly pure predicate instead. However, if you all feel
this is worth fixing, then I won't argue anymore.

I'll just add that this is an issue for the stable sort as well but that won't
be so easy to fix. The algorithm used is Timsort, which is a variant of merge
sort, meaning it allocates a buffer to store elements temporarily. The simplest
solution would be to move to an in-place algorithm like block sort [1] but then
you'll be losing the benefits of Timsort.

[1] https://en.wikipedia.org/wiki/Block_sort

--

Reply via email to