对象集合按照某个属性字段排序

//如有多个优惠券则取最大金额的那个
List<Coupon> couponList = Arrays.stream(item.getCouponInfo().getCouponList())
        .sorted(Comparator.comparing(Coupon::getDiscount).reversed()).collect(Collectors.toList());

版权声明:本文为weixin_43244841原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。