对象按某个属性值排序

Collections.sort(list, new Comparator<PriceTypeSkuNum>() {
            @Override
            public int compare(PriceTypeSkuNum o1, PriceTypeSkuNum o2) {
                if(o1.getPrice() > o2.getPrice()){
                    return 1;
                }
                if(o1.getPrice() == o2.getPrice()){
                    return 0;
                }
                return -1;
            }
        });

 

posted @ 2016-11-25 10:40  lskdcl  阅读(294)  评论(0编辑  收藏  举报