[Issue 13965] New: More handy schwartzSort
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sat Jan 10 03:56:15 PST 2015
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: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
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).
--
More information about the Digitalmars-d-bugs
mailing list