partition

fun <T> MutableList<T>.partition(k: Int, cmp: (T, T) -> Int)
fun <T> MutableList<T>.partition(rng: IntRange, k: Int, cmp: (T, T) -> Int)
fun <T> Array<T>.partition(k: Int, cmp: (T, T) -> Int)
fun <T> Array<T>.partition(rng: IntRange, k: Int, cmp: (T, T) -> Int)


fun <L, T> partition(elems: L, lt: Int, rt: Int, k: Int, get: L.(Int) -> T, cmp: (T, T) -> Int, swap: L.(Int, Int) -> Unit)

Partitions items with the given comparator. After partitioning, all elements left of k are smaller than all elements right of k with respect to the given comparator function.

This method implements the Floyd-Rivest selection algorithm: https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm