I know this has been asked before but I've checked every thread and couldn't find a solution. According to check50, my code for sort_pairs()
doesn't work, and I can't figure out what could be wrong with it. Here are the instructions. This is my code:
void sort_pairs(void)
{
int nswaps = -1;
pair temp;
do
{
nswaps = 0;
for (int i = 0; i < pair_count - 1; i++)
{
if (preferences[pairs[i].winner][pairs[i].loser] > preferences[pairs[i+1].winner][pairs[i+1].loser])
{
temp = pairs[i];
pairs[i] = pairs[i+1];
pairs[i+1] = temp;
nswaps++;
}
}
}
while (nswaps != 0);
}