Selection sort
From Algorithmist
With selection sort, you essentially take the smallest entry from the unsorted portion of an array and build a sorted array at the front, entry by entry.
[edit] Algorithm
- At each iteration find the smallest entry (the "key") in the unsorted portion of the array.
- Swap the "key" with the the ith entry.
[edit] Pseudo-code
- lst is an array
func selsrtI(lst)
max = length(lst)
for i from 0 to max
key = lst[i]
keyj = i
for j from i+1 to max
if lst[j] < key
key = lst[j]
keyj = j
lst[keyj] = lst[i]
lst[i] = key
return lst
end func

