daily pastebin goal
70%
SHARE
TWEET

Untitled

a guest Mar 14th, 2018 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Arrays.sort(unorderedArray,(a,b) -> Integer.compare(
  2.                         Integer.parseInt(b.substring(b.indexOf("was choosen <b>") + 15, b.indexOf(" times</b>"))),
  3.                         Integer.parseInt(a.substring(a.indexOf("was choosen <b>") + 15, a.indexOf(" times</b>")))
  4.                 ));
  5.    
  6. Comparator<String> comp = new Comparator<String>() {
  7.                     @Override
  8.                     public int compare(String a, String b) {
  9.                         int itemB = Integer.parseInt(b.substring(b.indexOf("was choosen <b>") + 15, b.indexOf(" times</b>")));
  10.                         int itemA = Integer.parseInt(a.substring(a.indexOf("was choosen <b>") + 15, a.indexOf(" times</b>")));
  11.  
  12.                         return itemA.compareTo(itemB);
  13.                     }
  14.                 };
  15.  
  16.  
  17.                 // sort the array
  18.                 Arrays.sort(unorderedArray, comp);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top