sort

fun <T : Comparable<T>> sort(array: Array<T>)(source)

Sorts the array in ascending natural order.

Parameters

array

array to sort


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

Sorts the array using the given comparator.

Counting sort is not directly applicable to generic types since it relies on integer indices — this overload falls back to a rank-based counting approach.

Parameters

array

array to sort

comparator

comparator to determine order