本文共 438 字,大约阅读时间需要 1 分钟。
package cn.edu.xmu.ru.utils;import java.util.Comparator;import cn.edu.xmu.ru.domain.Slashdot;public class RUComparator implements Comparator { @Override public int compare(Object o1, Object o2) { Slashdot one = (Slashdot)o1; Slashdot theother = (Slashdot)o2; if(one.getScore() <= theother.getScore()){ return -1; }else if(one.getScore() > theother.getScore()){ return 1; } return 0; }}
Collections.sort(lst, new RUComparator());
转载地址:http://kvwob.baihongyu.com/