}
//按两个元素排序
private static void sort2(List<RongYuScoreVO> lst){
Comparator<RongYuScoreVO> comparator = new Comparator<RongYuScoreVO>() {
public int compare(RongYuScoreVO s1, RongYuScoreVO s2) {
if (s1.getScore() != s2.getScore()){
return s1.getScore() - s2.getScore();
}
return s1.getFightForce() - s2.getFightForce();
}
};
Collections.sort(lst, comparator);
// Collections.reverse(lst);//倒序
}
输出结果为
for (RongYuScoreVO rongYuScoreVO : lst) {
System.out.println(rongYuScoreVO.getScore()+","+rongYuScoreVO.getFightForce());
}
1,2
1,23
4,1
4,11
4,13
5,23
6,23
6,66