TournamentSort

Tournament Sort.

Uses a tournament tree to repeatedly select the smallest element.

Time complexity:

  • Best: O(n²)

  • Average: O(n²)

  • Worst: O(n²)

Space complexity:

  • O(n)

Functions

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

Sorts using natural ordering.

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

Sorts using the provided comparator.