sort by field of object java 8 code example
Example: java sort arraylist of objects by field descending
List<User> sortedUsers = users.stream()
.sorted(Comparator.comparing(User::getCreatedOn).reversed())
.collect(Collectors.toList());
List<User> sortedUsers = users.stream()
.sorted(Comparator.comparing(User::getCreatedOn).reversed())
.collect(Collectors.toList());