here is the code
Code:
void sort(float* array, int length)
{
. . int i, changed;
. . float temp;
. . changed = 1; // assume we changed something
. . while(changed) // continue looping until we change nothing
. . {
. . . . changed = 0; // set the changed flag to nothing
. . . . for(i = 0; i < length-1; i++) // loop from the first to the second-to-last
. . . . {
. . . . . . if(array[i] > array[i+1]) // if this one is bigger than the one in front of it
. . . . . . { // swap them
. . . . . . . . changed = 1; // make sure we know we changed something
. . . . . . . . temp = array[i];
. . . . . . . . array[i] = array[i+1];
. . . . . . . . array[i+1] = temp;
. . . . . . } // end if swap
. . . . } // end for loop
. . // if we were able to get this far without changing anything, it must have
. . // been in the right order for every float!
. . } // end while
} // end function void sort(float*,int)