Skip to content

Instantly share code, notes, and snippets.

@sadedv
Created March 8, 2016 12:49
Show Gist options
  • Save sadedv/749e4ef6e311d9847608 to your computer and use it in GitHub Desktop.
Save sadedv/749e4ef6e311d9847608 to your computer and use it in GitHub Desktop.
Collections.sort
List list = new ArrayList(wordCountMap.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Integer, Integer>>() {
@Override
public int compare(Map.Entry<Integer, Integer> a, Map.Entry<Integer, Integer> b) {
return a.getValue() - b.getValue();
}
});
Collections.reverse(list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment