CycleSort

Cycle Sort.

An in-place, unstable sorting algorithm that minimizes the number of memory writes. Optimal when write cost is expensive. Performs O(n²) comparisons and O(n) writes in all cases.

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.