Bug 3946 – schwartzSort - SwapStrategy always unstable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2010-03-13T00:41:00Z
Last change time
2014-02-15T02:43:08Z
Assigned to
bugzilla
Creator
9il

Comments

Comment #0 by 9il — 2010-03-13T00:41:34Z
In the last line sort calling without "ss" (SwapStrategy) - it is looks like always unstable: module std.algorithm; void schwartzSort(alias transform, alias less = "a < b", SwapStrategy ss = SwapStrategy.unstable, Range)(Range r) if (isRandomAccessRange!(Range) && hasLength!(Range)) { alias typeof(transform(r.front)) XformType; auto xform = new XformType[r.length]; foreach (i, e; r) { xform[i] = transform(e); } auto z = zip(xform, r); alias typeof(z.front()) ProxyType; bool myLess(ProxyType a, ProxyType b) { return binaryFun!(less)(a.at!(0), b.at!(0)); } sort!(myLess)(z); /// <------------- }
Comment #1 by andrei — 2010-03-13T07:00:46Z
Thanks!
Comment #2 by bugzilla — 2010-08-13T03:56:53Z