CountingSort

Counting Sort.

Sorts elements by counting occurrences of each value. Efficient when the range of values (k) is not significantly larger than the number of elements (n).

Functions

Link copied to clipboard
fun <T : Comparable<T>> sort(array: Array<T>)

Sorts the array in ascending natural order.

fun <T> sort(array: Array<T>, comparator: Comparator<T>)

Sorts the array using the given comparator.