Selection Sort Selection Sort is an elementary sorting algorithm that is designed to minimize the number of exchanges that are performed. It works by making N-1 passes over the unsorted portion of the array, each time selecting the largest value. This value is then moved into its final sorted position with a single exchange. Here is a procedure that implements Selection Sort, assuming a global array a[ ] with n elements, and a procedure called swap( ). procedure selection_sort; var i : integer; top : integer; max : integer; begin for top := n downto 2 do begin max := top; for i := 1 to top-1 do if a[i] > a[max] then max := i; swap(a[top],a[max]) end end; DOWNLOAD selection.pas (complete program) Selection Sort requires about N2/2 comparisons and about N exchanges, and is quite insensitive to the original ordering of the input data.