selectionSort

Selection sort is an inefficient* primitive sorting algorithm. Principle: Go through the list and find the smallest element in the list. After it was found, swap the element with the element on Nth place in the list, where N is the number of iterations that was already done.

Time complexity: O(n^2) in all cases. Space complexity: O(1) for the original list.


fun <T : Comparable<T>> MutableList<T>.selectionSort(showPasses: Boolean = false)