LoginSignup
1
1

More than 5 years have passed since last update.

map内のvalueソート

Last updated at Posted at 2013-01-09
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;
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1