You are viewing a single comment's thread. Return to all comments →
You can simplify the function comp if you convert it into this:
comp
bool comp(Player &A, Player &B){ return A.score==B.score and A.name<B.name or A.score>B.score; }
Also and just for fun, it can use a lambda expression in its place:
vector<Player> comparator(vector<Player> players) { sort(players.begin(),players.end(),[](Player &A,Player &B){return A.score==B.score and A.name<B.name or A.score>B.score;}); return players; }
Seems like cookies are disabled on this browser, please enable them to open this website
Sorting: Comparator
You are viewing a single comment's thread. Return to all comments →
You can simplify the function
comp
if you convert it into this:Also and just for fun, it can use a lambda expression in its place: