PigeonholeSort

Pigeonhole Sort.

Works by creating "pigeonholes" (buckets) for each value in the range min, max, placing each element into its corresponding hole, then collecting them back in order.

Only applicable to integer-like types with a bounded, reasonably small range.

Time complexity: O(n + range) Space complexity: O(range)

Functions

Link copied to clipboard
fun sort(array: IntArray)
fun <T> sort(list: MutableList<T>, key: (T) -> Int): MutableList<T>

fun <T> sort(array: Array<T>, key: (T) -> Int): Array<T>

Generic overload for any type mappable to an Int key. The key lambda extracts the integer rank used for bucketing.