Contains code for sorting arrays using various algorithms.
See also:
Static methods
staticinsertionSort<T>(input:Array<T>, compare:CompareFunction<T>):Void
Sorts the input array using the insertion sort algorithm.
Stable and is very fast on nearly-sorted arrays,
but is inefficient O(n^2) in "worst-case" situations.
Parameters:
input | The array to sort in-place. |
|---|---|
compare | The comparison function to use. |
staticmergeSort<T>(input:Array<T>, compare:CompareFunction<T>):Void
Sorts the input array using the merge sort algorithm.
Stable and guaranteed to run in linearithmic time O(n log n),
but less efficient in "best-case" situations.
Parameters:
input | The array to sort in-place. |
|---|---|
compare | The comparison function to use. |
staticquickSort<T>(input:Array<T>, compare:CompareFunction<T>):Void
Sorts the input array using the quick sort algorithm.
More efficient on smaller arrays, but is inefficient O(n^2) in "worst-case" situations.
Not stable; relative order of equal elements is not preserved.
Parameters:
input | The array to sort in-place. |
|---|---|
compare | The comparison function to use. |
See also:
https://stackoverflow.com/questions/33884057/quick-sort-stackoverflow-error-for-large-arrays Fix for stack overflow issues.