Concept

How can method references and Comparator methods make ordering more concise?

ComputerScienceOne / Java 8: Lambda Expressions

"We can make this even more terse using method references, another new feature in Java 8.\n\n//using getters as key extractors\n\nmyList.sort(\n\nComparator.comparing(Student::getLastName)\n\n.thenComparing(Student::getFirstName)\n\n.thenComparing(Student::getGpa));\n\nThere are several other convenient methods provided by the updated Comparator interface. For example, the reversed() member method returns a new Comparator that defines the reversed order. The static methods, nullsFirst() and nullsLast() can be used to modify a Comparator to order null values."

Related Ideas

How can method references and Comparator methods make ordering more concise? | ComputerScienceOne | Bifalgorithm | Bifalgorithm