Monday, June 11, 2007 06:37 PM
If array[j] value is comparatively less than array[i] value, then:
temp = array[j];
array[j] = array[i];
array[i] = temp;
For the most naive algorithm possible, for an array of size N, start looping i=0 to (N-1) and j=(i+1) to N, nested-loop fashion. Compare values and swap if needed, as above. Caution: this is the slowest, worst possible way to code a sort routine ... entire series of college classes exist to explore the faster ones.