CocktailSort

Cocktail Shaker Sort.

A bidirectional variant of Bubble Sort that traverses the array in both directions alternately, moving large elements right and small elements left in the same pass.

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.