std/sort
Comparator-based sort on [T] arrays.
Stable, O(n log n). Returns a freshly-allocated sorted copy ; the input array is never mutated. Internally a top-down merge sort with an insertion-sort cutoff for sub-ranges of length ≤ 16 (avoids the merge overhead: same cutoff Java's TimSort uses by default).
Functions
sort :: fn<T>(arr: T[], compare: fn(T, T) -> bool) -> T[] Return a fresh array containing arr's elements in sorted order. The
input is never mutated. Equal elements keep their input order, so the
sort is stable. Complexity O(n log n) (top-down merge sort with an
insertion-sort fallback below INSERTION_CUTOFF items).
Parameters
| arr | T[] | the input array. Untouched ; the returned array is a new allocation. |
| compare | fn(T, T) -> bool | strict predicate : compare(a, b) is true iff a must come strictly before b in the result. Reflexivity (compare(x, x) == false) is required for stability. |
Returns
T[] a new array with the same elements in sorted order.