SSVISUAL.COM

Selection Sort

It's like picking the smallest thing, putting it first, then picking the next smallest until everything is in order, like sorting playing cards.

Pseudocode

function selection_sort(list):
     FOR i = 1 to n - 1
      min = i     
      FOR j = i+1 to n 
         IF list[j] < list[min] THEN
            min = j;
         END IF
      END for
      IF indexMin != i  THEN
         swap list[min] and list[i]
      END IF
   END FOR
END function
                

Terminal

Current Index:

Current Min Value:

Cyan indicates the current minimum value.

Yellow indicates the current index.