List<TraineeVo> l= traineeDao.getTrainees(); Collections.sort(l,new Comparator<TraineeVo>(){ @Override public int compare(TraineeVo t1,TraineeVo t2){ return t1.getDates().compareTo(t2.getDates()); } }); public class TraineeVo { private String name; private String unit; private String duty; private String dates; }
按照TraineeVo中的date属性排序(规则自定);
Collects集合工具类中的sort方法自定义compare规则(重写compare方法);