Good afternoon,
I was attempting to use a bubble sort to place my results of the array in order and am only able to sort the second column. For some reason, I am not able to get the rows to stay together. Any pointers would be appreciated.
Code:
void scores_sort(void)
{
int y;
for(int i=0;i<score;i++)
{
for(int j=0; j<teams-i; j++)
{
if(game[j+1][1] < game[j][1]) // swap values
{
y = game[j][1];
game[j][1] = game[j+1][1];
game[j+1][1] = y;
}
}
}
for(i=0; i<score; i++)
{
for(j=0;j<teams;j++){
printf("%d\t", game[i][j]);
}
printf("\n");
}
return;
}