Skip to content
Search

Selection sort

lastmod 2018-08-17created 2015-11-101 edits

Selection sort is an in-place sorting algorithm that works in the following order.

  1. Find the minimum value in the given list.
  2. Swap that value with the value at the front (a pass).
  3. Swap the rest of the list, excluding the first position, in the same way.

Assuming comparisons take constant time, sorting a given list of n items this way takes O(n2) time.

See also

Favorite site