Help us understand the problem. What is going on with this article?

map内のvalueソート

More than 5 years have passed since last update.
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;
}
zaoriku0
言語: java, android, python, perl, php, cakePHP, C#, C , アセンブラ, basic, R, octave, maple, テーマ: テキストマイニング, NLP, 機械学習, MAS, 市場予測, gameプログラミング hatenaアカ: ZAORIKU
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away