List列表排序,对象列表排序

Java如何根据对象某一属性值大小对列表进行排序呢?
下面介绍一种很傻瓜的排序

 Collections.sort(someObjList, new Comparator<SomeObject>() {
            public int compare(SomeObject s1, SomeObject s2) {
                return s1.getProperties().compareTo(s2.getProperties());
            }
        });

这里定义的对象属性时int型的。

猜你喜欢

转载自blog.csdn.net/leegoowang/article/details/80858996