list排序
需要使用JDK1.8及以上
方式一:
升序
list.sort((x, y) -> Integer.compare(x.getCusBuyCount() + x.getCusRentCount(), y.getCusBuyCount() + y.getCusRentCount()));
降序
list.sort((y, x) -> Integer.compare(x.getCusBuyCount() + x.getCusRentCount(), y.getCusBuyCount() + y.getCusRentCount()));
方式二:
升序:
list.sort(Comparator.comparing(BusinessLookReportVo::getCusBuyCount));
降序
list.sort(Comparator.comparing(BusinessLookReportVo::getCusBuyCount).reversed());
List
public static void main(String[] args) {
List