Posted by: micky_mouse October 31, 2008
Login in to Rate this Post:
0
?
Test it. I may be wrong. I did not test it.
/// Routine sorts the array that holds integer values. Make sure list[i] returns integer but NOT string or object or double or any
//boolean changed; not needed//changed = false; not needed
int temp = 0;
for(int i = 0; i < list.length - 1; i++){
//initialize the temp varaible for every spin
temp = 0;
//Swap it only if first value is greater than next value
if(list[i] > list[i + 1]){
temp = list[i];
list[i] = list[i+1];
list[i+1] = temp;
//
swap list[i] with list[i + 1];
// changed = true; not needed
} }