Sorting algorithms/Strand sort: Difference between revisions

→‎Faster version using slices: we're already using the identifier "result" in the enclosing function, better not use it also in the nested function, "res" is clear enough
(Small improvements in second D entry)
(→‎Faster version using slices: we're already using the identifier "result" in the enclosing function, better not use it also in the nested function, "res" is clear enough)
Line 285:
T[] strandSort(T)(/*in*/ T[] list) pure nothrow {
static T[] merge(T[] left, T[] right) pure nothrow {
T[] resultres;
while (!left.empty && !right.empty) {
if (left.front <= right.front) {
resultres ~= left.front;
left.popFront;
} else {
resultres ~= right.front;
right.popFront;
}
}
return resultres ~ left ~ right;
}
 
Anonymous user