private List<Map.Entry> valueSort(Map<Integer, Integer> tAsMap2) {
List<Map.Entry> entries = new ArrayList<Map.Entry>(tAsMap2.entrySet());
Collections.sort(entries, new Comparator(){
public int compare(Object o1, Object o2){
Map.Entry e1 =(Map.Entry)o1;
Map.Entry e2 =(Map.Entry)o2;
return ((Integer)e2.getValue()).compareTo((Integer)e1.getValue());//降順
//return ((Integer)e1.getValue()).compareTo((Integer)e2.getValue());//昇順
}
});
return entries;
}
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme
List of users who liked
11