We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
For cleaner comparisions could do some op overloading for the fun of it.
// something like this for p1 < p2booloperator<(Player&p1,Player&p2){if(p1.score!=p2.name){returnp1.score<p2.score;}else{// compare names thenreturnp2.name<p1.name;}}
That way you dont even need a compare function, you can just compare the player object using the '<' operator.
Cookie support is required to access HackerRank
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 →
For cleaner comparisions could do some op overloading for the fun of it.
That way you dont even need a compare function, you can just compare the player object using the '<' operator.