Sorts a Xar in place with a three-way comparator (negative, zero or positive). Despite the name it is a heap sort, not a quicksort.
It is O(n log n) in the worst case and unstable: equal elements may change their relative order. The
comparator should be a strict weak order; an inconsistent one only gives an unspecified order. Unlike
Sort.quick_sort it has no key form and no insertion-sort fast path, and it returns nothing.
array: Xar(int, 2, 4);
for value: int.[3, 1, 2] xar_add(*array, value);
quick_sort(array, (a: int, b: int) -> int { return a - b; });
assert(array[0] == 1 && array[2] == 3);
xar_reset(*array);quick_sort :: (array: $T/Xar, f: (T.Element_Type, T.Element_Type) -> $R)
All three public names are this one heap sort.
Parameters
- array: $T/Xar
- f: (T.Element_Type, T.Element_Type) -> $R