quickselect
quickselect<
T>(items,k,compare):T
Defined in: select/quickselect.ts:15
Rearranges items in place until the element at index k is the one a full
sort by compare would have put there, and returns it — Hoare’s selection
algorithm.
O(n) average, O(n²) worst case.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”T[]
Working array, modified in place. k must be a valid index.
number
The rank to resolve (0-based).
compare
Section titled “compare”Comparator<T>
Total order to select by.
Returns
Section titled “Returns”T
The value that belongs at index k.