Jump to content

Sorting algorithms/Strand sort: Difference between revisions

m
→‎{{header|Sidef}}: modified the code to work with the latest version of Sidef
m (→‎{{header|Sidef}}: modified the code to work with the latest version of Sidef)
Line 1,456:
var out = [];
while (x && y) {
given (x[-1] <=> y[-1]) {
>when ( 1) { out.prepend(x.pop) }
>when (-1) { out.prepend(y.pop) }
 : default { out.prepend(x.pop, y.pop) }
};
}
x + y + out;
}
Line 1,473 ⟶ 1,474:
}
}
};
return out;
}
 
Line 1,481 ⟶ 1,482:
while (var strd = strand(x)) {
out = merge(out, strd);
};
return out;
}
 
var a = 10.of {100.rand.int};
say "Before: #{a}";
say "After: #{strand_sort(a.copy)}";</lang>
 
{{out}}
2,747

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.