If I have an int[3] array like such:
score_list[3] = [ 1, 2, 0]
Where each location in the array corresponds to a specific Document Number:
score_list[0] = D1
score_list[1] = D2
score_list[2] = D3
What would be the easiest way to sort the array in Descending order, keeping track of the place of each moved int
Where (after sort):
score_list[3] = [ 2, 1, 0]
And
score_list[0] = D2
score_list[1] = D1
score_list[2] = D3
I only need to print in descending order, not actually rearrange the int array, so:
for (int i=0; i<3; i++)
{
if (score_list[0] > score_list[1] && score_list[2])
printf("D%d-%d",i, score_list[0]);
if (score_list[1] > score_list[0] && score_list[2])
printf("D%d-%d", i, score_list[1]);
if (score_list[2] > score_list[0] && score_list[1])
printf("D%d-%d", i, score_list[2]);
}
Would print the highest number first, then I would compare the last 2, I just feel like this takes too long and there must be a more efficient way