For count going from 0 through length - 2
Find minimum value in list[count . . length - 1]
Swap minimum value with list[count]
Notice that the loop only goes up to length - 2; when count equals
length - 1, the last value list[count] will be in the correct position.
Suppose you have two integer variables, x and y. To swap (exchange) their contents, why can't you simply do the following?
Swapping the contents of two variables requires a temporary variable. You would need to do the swap this way:x = y; y = x;
A graphical view of this sort method is here.int temp; temp = x; x = y; y = temp;
Next page