Selection Sort Algorithm (Python)

Tags: , ,

Selection sort is one of the simplest sorting algorithms. This tutorial described how to implement selection sort algorithm in python.

The basic idea of selection sort is that it repeatedly select the smallest item in list A[i+1:], and exchange it with the item at A[i].

It works as follows:

  1. Find the smallest item in the array, and exchange it with the first entry.
  2. Find the next smallest item in the array, and exchange it with the second entry.
  3. Continue such a process until the whole array is sorted.