I have the algorithm for sort by last name, but I am having trouble figuring out how to sort by last name, then if two people have the same last name, sort by their first name.
void sortLastName(FRIEND friends[ARRAY_MAX], int& count) {
FRIEND temp;
for(int i = 0; i < count - 1; i++) {
for (int j = i + 1; j < count; j++) {
if (stricmp(friends[i].lastName, friends[j].lastName) > 0) {
temp = friends[i]; //swapping entire struct
friends[i] = friends[j];
friends[j] = temp;
}
}
}
}
=== EDIT ====================
I don't want to use STD sort()