Selection sort

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.

Algorithm

 * 1) At each iteration find the smallest entry (the "key") in the unsorted portion of the array.
 * 2) Swap the "key" with the the ith entry.

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

--Romeo61 21:22, 17 Aug 2005 (EDT)