Comparator<TwoTuple<Integer, Double>> com = new Comparator<TwoTuple<Integer, Double>>() {
public int compare(TwoTuple<Integer, Double> o1,
TwoTuple<Integer, Double> o2) {
if (o1.getValue().doubleValue() > o2.getValue().doubleValue())
return -1;
else if (o1.getValue().doubleValue() < o2.getValue().doubleValue())
return 1;
else
return 0;
}
};
Collections.sort(tempList, com);
注意:对ArrayList<ArrayList<String>> resultlist = new ArrayList<ArrayList<String>>();必须要对ArrayList里面的每一个对象初始化,要不然报空指针错误
for (int i = 0; i < totalUsers; ++i)
resultlist.add(new ArrayList<String>());
【代码积累】对ArrayList<TwoTuple<Integer,Double>>对象自定义排序
最新推荐文章于 2023-01-09 11:24:49 发布