https://issues.dlang.org/show_bug.cgi?id=13965
Issue ID: 13965
Summary: More handy schwartzSort
Product: D
Version: D2
Hardware: x86
OS: Windows
Status: NEW
Severity: enhancement
Priority: P1
Component: Phobos
Assignee: [email protected]
Reporter: [email protected]
This is correct code:
void main() {
import std.algorithm: schwartzSort, SwapStrategy, equal;
import std.math: abs;
auto a = [1, -10, 2];
auto s = a.schwartzSort!(abs, q{a < b}, SwapStrategy.stable);
assert(s.equal([1, 2, -10]));
}
For practical reasons I suggest to support this kind of code too:
auto s = a.schwartzSort!(abs, SwapStrategy.stable);
(This means the "less" predicate can be omitted and replaced by the
SwapStrategy).
--