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); /// <------------- }
Thanks!
http://www.dsource.org/projects/phobos/changeset/1845