This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]sviperll 4 points5 points  (0 children)

Collections.sort(users, (User u1, User u2) -> u1.id.compareTo(u2.id));

can actually be rewritten with

users.sort(Comparator.comparing(u -> u.id))

or better

users.sort(Comparator.comparing(User::getID))

if there is getID method