# PSET3 Tideman: sort_pairs check50 error, help please

I can't figure out why check50 rejects my sorting algorithm, it works fine for me. I realize it's a little more complicated than the ones I found in the forum. Anyhow, I'd really appreciate some feedback. I created a difference_array to store the balance the margin of the victory

``````void sort_pairs(void)
{
int filler_variable_2 =  int filler_variable = pair_count;
int max_difference = 0;
int marker = 0;

//1. Creating an array that is identical to pairs[]
typedef struct
{
int winner;
int loser;
}
pair_mirrored;
pair_mirrored pairs_mirrored[pair_count];

for (int j = 0; j < filler_variable; j++)
{
//2. Going through the difference_array and finding the largest entry)
for (int i = 0; i < filler_variable; i++)
{
if (difference_array[i] > max_difference)
{
max_difference = difference_array[i];
marker = i;
}
}
//3. Copy the the pair with the largest difference at the right spot in the original array

pairs_mirrored[j].winner = pairs[marker].winner;
pairs_mirrored[j].loser  = pairs[marker].loser;

//4.Deleting the entry in the difference_array, so that when I'm looking through it, I won't
mistake the same entry for the largest
difference_array[marker] = 0;

//5.Setting the max_difference and marker back to 0
max_difference = 0;
marker = 0;
}

//6.Copying the mirrored array back to the original pairs array
for (int w = 0; w < pair_count; w++)
{
pairs[w].winner = pairs_mirrored[w].winner;
pairs[w].loser  = pairs_mirrored[w].loser;
}
return;
}
``````