list按对象属性进行排序

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/winteriscomming/article/details/81531156

/**
     * 对层级进行排序  正序
     * @param levelList
     */
    private void sortLevel(List<Long> levelList) {
        levelList.sort(new Comparator<Long>() {
            @Override
            public int compare(Long o1, Long o2) {
                if(o1 < o2){
                    return -1;
                }else{
                    return 1;
                }
            }
        });
    }

partRoutingList.sort((o1, o2) -> o1 == null ? (o2 == null ? 0 : -1) : o2.getPriority().compareTo(o1.getPriority()));

Collections.sort(removedData, new Comparator<PartAssembly>() {
                public int compare(PartAssembly arg0, PartAssembly arg1) {
                    return arg0.getOperationType().compareTo(arg1.getOperationType());
                }
            });

猜你喜欢

转载自blog.csdn.net/winteriscomming/article/details/81531156