how would i make a function that uses a modified bubble sort that the comparison for out-of-order elements takes into account all three fields: totalPoints, lastName and firstName, in decreasing order of importance. In other words... sort by totalPoints as the primary criterion and put bigger point totals before smaller point totals.
in c++
if i have a struct
struct Student {
string firstName, lastName;
int pointTotal;
};
and the code in the first image
how would i make a function that uses a modified bubble sort that the comparison for out-of-order elements takes into account all three fields: totalPoints, lastName and firstName, in decreasing order of importance. In other words... sort by totalPoints as the primary criterion and put bigger point totals before smaller point totals. Then among students with the same totalPoints, sort by lastName, putting students with an alphabetically smaller last name before students with an alphabetically bigger last name. Finally among students with the same totalPoints and lastName, sort by firstName, again in ascending order. and the output should look like the second image
Step by step
Solved in 3 steps