2 ms·
A: For small arrays. I would add: particularly if you need a stable sort algorithm, which is either complex (Block Sort) or uses O(n) space (Merge Sort).
by beeforpork 10mo ago
A: For small arrays. I would add: particularly if you need a stable sort algorithm, which is either complex (Block Sort) or uses O(n) space (Merge Sort).
- thomasmg 10mo agoThere is stable in-place merge sort [1], which is O(n*log(n)^2) and not that complex or hard to implement (about 80 lines, and that includes the ~15 lines of binarySearch, which you might need anyway). [1] https://github.com/thomasmueller/bau-lang/blob/main/src/test/java/org/bau/stdlib/sort/MergeSort.java https://github.com/thomasmueller/bau-lang/blob/main/src/test...