要先对amount进行升序排序,再针对amount相同的 根据id升序排序
List.sort(Comparator.comparing(Entity::getAmount).thenComparing(Entity::getId));
List.stream().sorted(Comparator.comparing(Entity::getAmount).thenComparing(Entity::getId)).collect(Collectors.toList());
要先对amount进行降序排序,再针对amount相同的 根据id升序排序
List.sort(Comparator.comparing(Entity::getAmount).reversed().thenComparing(Entity::getId));
List.stream().sorted(Comparator.comparing(Entity::getAmount).reversed().thenComparing(Entity::getId)).collect(Collectors.toList());