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());