Advertisement
Guest User

java sorting

a guest
Sep 20th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.64 KB | None | 0 0
  1.  public static void sortBySubtitle(List<MediaBrowserCompat.MediaItem> list) {
  2.  
  3.         Collections.sort(list, (o1, o2) -> {
  4.  
  5.             String subtitle1 = ((String) o1.getDescription().getSubtitle());
  6.             String subtitle2 = ((String) o2.getDescription().getSubtitle());
  7.  
  8.             int compResult = subtitle2.compareToIgnoreCase(subtitle1);
  9.  
  10.             if (compResult != 0)
  11.                 return compResult;
  12.  
  13.             String title1 = ((String) o1.getDescription().getTitle());
  14.             String title2 = ((String) o2.getDescription().getTitle());
  15.  
  16.             return title1.compareToIgnoreCase(title2);
  17.         });
  18.  
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement