Concept

How can Comparator order Student objects by different fields?

ComputerScienceOne / Comparators

"Comparators can define several orderings for Student objects based on one or more member variables. A comparator named byName orders students by last name and then first name: if the last names are equal, it compares the first names; otherwise, it compares the last names. A byNameDesc comparator reverses those comparisons to order last names and first names in descending, Z-to-A order. A byId comparator orders Student objects by ID in ascending order by returning a.getId().compareTo(b.getId()). The source also introduces a comparator that orders Student objects by GPA in descending order."

Related Ideas

How can Comparator order Student objects by different fields? | ComputerScienceOne | Bifalgorithm | Bifalgorithm