I am sorting a file containging student records by grade letter, highest to lowest. I can sort it but my question is how do I make say a B+ be above a B in the order? This is my code:
insert
Code:
void sortListGrade(STUDENT records[], int count)
{
STUDENT tempData;
int smallest;
int current;
int walk;
for (current = 0; current < count - 1; current++)
{
smallest = current;
for (walk = current + 1; walk <= count - 1; walk++)
{
if ((strcmp(records[walk].grade, records[smallest].grade)) < 0)
smallest = walk;
}
tempData = records[current];
records[current] = records[smallest];
records[smallest] = tempData;
}
return;
}
right now its printing
A
A
B
B+
B-
B-
...
I need it to print
A
A
B+
B
B-
B-
...