The array to sort.
The k-th element index.
Optionalleft: numberThe index of the left part of the range. Default 0.
Optionalright: numberThe index of the right part of the range.
Optionalcompare: FunctionAn optional comparison function. Is passed two elements and should return 0, 1 or -1.
A Floyd-Rivest quick selection algorithm.
Rearranges the array items so that all items in the [left, k] range are smaller than all items in [k, right]; The k-th element will have the (k - left + 1)th smallest value in [left, right].
The array is modified in-place.
Based on code by Vladimir Agafonkin