Guest User

Untitled

a guest
Dec 15th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. private static void sortList(List<players> players) {
  2.  
  3. Collections.sort(players, new Comparator<Object>() {
  4.  
  5. public int compare(Object o1, Object o2) {
  6.  
  7. Integer firstScore = ((players) o1).getScore();
  8. Integer secondScore = ((players) o2).getScore();
  9. int comparedValue = firstScore.compareTo(secondScore);
  10.  
  11. if (comparedValue != 0) {
  12. return comparedValue;
  13. }
  14. else {
  15. Double timeOne = ((players) o1).getTime();
  16. Double timeTwo = ((players) o2).getTime();
  17. return timeOne.compareTo(timeTwo);
  18. }
  19. }
  20. }
  21. );
  22. }
Add Comment
Please, Sign In to add comment