RadixSort

Radix Sort.

A non-comparative sorting algorithm that sorts integers by processing individual digits from least significant to most significant. Uses counting sort as a stable subroutine per digit. Achieves O(nk) time where k is the number of digits in the max value.

Note: this implementation handles non-negative integers only. For generic types, elements are sorted by their natural or comparator-defined rank, falling back to comparison-based counting.

Functions

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

Sorts the array in ascending natural order.

fun sort(array: IntArray)

Sorts an IntArray in ascending order.

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

Sorts the array using the given comparator.