Multiconditional sort

Method 1 uses sorted multiple times

deliveryList= deliveryList.stream().sorted(Comparator.comparing(SaleMonthPlanDTO::getYearMonth).reversed())
                .sorted(Comparator.comparing(SaleMonthPlanDTO::getSaleOrgCode).reversed())
                // Use reversed to change into descending order
                .sorted(Comparator.comparingDouble(SaleMonthPlanDTO::getCompleteRateNotNull).reversed()).collect(Collectors.toList());

Copy the code

Method 2 uses thenComparing method

 deliveryList = deliveryList.stream()// Use reversed to change into descending order
                .sorted(Comparator.comparingDouble(SaleMonthPlanDTO::getCompleteRateNotNull).reversed()
                        .thenComparing(SaleMonthPlanDTO::getSaleOrgCode)
                        .thenComparing(Comparator.comparing(SaleMonthPlanDTO::getYearMonth).reversed()))
                .collect(Collectors.toList());
Copy the code

Note that the sorting condition of mode 1 is reversed when it is used, so mode 2 thenComparing method is recommended