I've got an assignment that requires me to use selection sort in descending order, and here's my code so far:
Code:
void SortRecord( float grades[] )
{
int i, j;
int min, temp;
for( i = 0; i < (STUDENT_RECORDS - 1); i++ )
{
min = i;
for( j = (i + 1); j < STUDENT_RECORDS; j++ )
{
if( grades[j] < grades[min] )
min = j;
}
temp = grades[i];
grades[i] = grades[min];
grades[min] = temp;
}
for( i = 0; i < STUDENT_RECORDS; i++ )
{
printf( "%.1f\n", grades[i] );
}
printf( "\n" );
}
This works grand for sorting in ascending order, but I dont know what to change to get it to go the other way.
I'm still working on grasping the flow of logic and code here, which is why I'm not simply using trial and error to solve the problem. Any help is appreciated. Thanks