Selection Sort

Find the minimum and swap it to the front.

Selection sort repeatedly finds the minimum element and moves it to its correct position.

The idea: Divide the array into sorted (left) and unsorted (right) portions. Find the minimum in the unsorted portion. Swap it to the end of the sorted portion. Repeat.

Walkthrough for [64,25,12,22,11][64, 25, 12, 22, 11]:

1.1. Find min (1111), swap with first: [11,25,12,22,64][11, 25, 12, 22, 64]

2.2. Find min in rest (1212), swap: [11,12,25,22,64][11, 12, 25, 22, 64]

3.3. Find min in rest (2222), swap: [11,12,22,25,64][11, 12, 22, 25, 64]

4.4. Find min in rest (2525), already in place: [11,12,22,25,64][11, 12, 22, 25, 64]