Fig. 4 - Selection Let A be an array with n elements.
for (i = 0 ; i < n-1 ; i++) { index = i; for(j = i+1 ; j < n ; j++) { if(A[j] < A[index]) { index = j; } } temp = A[i]; A[i] = A[index]; A[index] = temp; }