Advertisement
takieddine

Untitled

Sep 23rd, 2019
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. Collections.sort(arrayList, new Comparator<model>() {
  2. @Override
  3. public int compare(model o1, model o2) {
  4.  
  5. int c = 0; ///// sorting teamplaces ( 1 - 2 - 3 - 4 )
  6. if(c == 0) {
  7. Integer p = o1.getTeamsplaces();
  8. Integer l = o2.getTeamsplaces();
  9.  
  10. int result = p.compareTo(l);
  11. if (result != 0) {
  12. return result;
  13. }
  14. }
  15. if (c == 0) { //// sorting teams by points
  16. Integer h = Integer.parseInt(o1.getPoints());
  17. Integer s = Integer.parseInt(o2.getPoints());
  18. if (h > s)
  19. return -1;
  20. else if (h < s)
  21. return 1;
  22.  
  23. }
  24. if (c == 0) { //// sorting teams by goals difference
  25. Integer a = Integer.parseInt(o1.getDifference());
  26. Integer b = Integer.parseInt(o2.getDifference());
  27. if (a < b)
  28. return -1;
  29. else if (a > b)
  30. return 1;
  31. else return 0;
  32.  
  33. }
  34. return c;
  35. }
  36. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement