Created
March 8, 2016 12:49
-
-
Save sadedv/749e4ef6e311d9847608 to your computer and use it in GitHub Desktop.
Collections.sort
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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