Selection sort is a method of sorting which consistently compares (lowest values if ascending order) values and switches them for each and every placement of an array (first, second, third…last etc.), in some order (ex: ascending).
SELECTION-SORT(A)
1. for j ← 1 to n-1
2. smallest ← j
3. for i ← j + 1 to n
4. if A[ i ] < A[ smallest ]
5. smallest ← i
6. Exchange A[ j ] ↔ A[ smallest ]
Example 2
can be done quickly with small amounts of data
simple to create and use
does not need temporary storage to hold sorted data as it is sorted immediately, not sorted and stored somewhere else.
-can take extremely long if the list contains a lot of values to be sorted (more numbers = more to check and repeat).