Selection Sort is an algorithm used to sort an array or list that is considered to have a complexity O(n²). This sorting algorithm is considered to be slightly more efficient than Bubble Sort because there is only one exchange per pass. Selection sort, although not the most efficient, can popular due to its simplicity.

How it Works:

Given a list (or array), selection sort iterates over the list (referred to as a pass) until it is sorted. On each pass, the largest value is "selected" and moved to the end. Because that value is now considered "sorted", that element will no longer be considered in further passes. This process is repeated until the list is sorted. There are other popular implementations that "select" the smallest value on each pass as well.

Below is a gif that shows this process using the smallest value approach (See my Python implementation at bottom):

selection sort

Python: