MergeSort

Merge Sort.

A divide-and-conquer algorithm that recursively splits the array in half, sorts each half, then merges them back together. Guarantees O(n log n) time in all cases with O(n) extra space.

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.