C/C++ Arena

Step 5 of 5

operator< and sorting

std::sort (from <algorithm>) orders anything that has a <. Define operator< and your own type becomes sortable:

std::vector<Player> team = ...;
std::sort(team.begin(), team.end());

(Vectors are the next module; for now just know team.begin(), team.end() means "the whole vector".)

Your turn: define operator< for Player so sorting puts the most kills first, and for equal kills, the name alphabetically first.

Previous: operator[]