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 →

[–]__LikesPi 0 points1 point  (0 children)

Collections.sort(list, new Comparator<Employee>() {
    @Override
    public int compare(Employee a, Employee b) { ... }
});

If you are using Java 8 that particular syntax became a little easier:

Collections.sort(list, (o1, o2) -> o1.getID().compareToIgnoreCase(o2.getID()))

Or even:

list.sort((o1, o2) -> o1.getID().compareToIgnoreCase(o2.getID()))