Go to the first, previous, next, last section, table of contents.


|sort

Function: |sort { [] -> [] }
file: job.t
package: muf
status: alpha

Sort the entries in a block:

Stack: 
20 seq[
Stack: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
|unsort
Stack: [ 4 3 15 13 11 12 18 19 10 17 9 7 2 6 1 16 8 5 14 0 |
|sort
Stack: [ 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |

This uses a HeapSort driven by the standard Muq comparison function. HeapSort is a simple, fast, stable O(n*log(n)) sort. Its best-case performance isn't quite as good as QuickSort's best-case performance, but HeapSort's worst-case performance is the same as its best-case performance, while QuickSort's worst-case performance is catastrophic.


Go to the first, previous, next, last section, table of contents.