重写Collections实现自定义排序

Collections.sort(List<Object>, new Comparator<Object>() {
    public int compare(Object o1, Object o2) {
        return o1.getSort().compareTo(o2.getSort());
    }
});
Collections.sort(articles, new Comparator<Article>() {
    public int compare(Article kf1, Article kf2) {
      return kf1.getSort().compareTo(kf2.getSort());
    }
});

 

posted @ 2016-05-12 16:14  InkYi  阅读(356)  评论(0编辑  收藏  举报