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.
"data" is list (of objects created from class Player).
For sorting the elements in data (based on attributes "score" & "name"), we are comparing 2 objects at a time (using the comparator() method of class Player). Its very similar to the concept when two items are being compared in Bubble sort or Quick sort.
Hope it helps.
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 →
"data" is list (of objects created from class Player).
For sorting the elements in data (based on attributes "score" & "name"), we are comparing 2 objects at a time (using the comparator() method of class Player). Its very similar to the concept when two items are being compared in Bubble sort or Quick sort.
Hope it helps.