Concept
How can a Comparator sort Student objects by GPA?
ComputerScienceOne / Searching
"Comparator<Student> byGpa = new Comparator<Student>() {\n\n@Override\n\npublic int compare(Student a, Student b) {\n\nreturn b.getGpa().compareTo(a.getGpa());\n\n}\n\n};\n\nWe now turn our attention to the search and sorting methods provided by the JDK. Most of these methods are generic implementations that either sort an array or collection using the natural ordering or take a parameterized Comparator<T> to determine the ordering."
Related Ideas
- How can Comparator order Student objects by different fields?ComputerScienceOne · Comparators
- How can comparator functions order Student structures?ComputerScienceOne · Comparator Functions
- How does a Comparator determine the order of two elements?ComputerScienceOne · Comparators
- What is a comparator function and how does it determine element order?ComputerScienceOne · Comparator Functions
- How do the Arrays and Collections classes sort elements?ComputerScienceOne · Sorting