Reverse the order of a bubble sort?
How to reverse the order of this bubble sort?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
void bubblesort(char arrray[])
{
int i, j, flag = 1;
int temp;
int numLength = 20;
for(i = 1; (i <= numLength) && flag; i++)
{
flag = 0;
for (j=0; j < (numLength -1); j++)
{
if (arrray[j+1] > arrray[j])
{
temp = arrray[j];
arrray[j] = arrray[j+1];
arrray[j+1] = temp;
flag = 1;
}
}
}
return;
}
|
Use < instead of >.
Last edited on
Topic archived. No new replies allowed.