Skip to content

Glossary: Java Beyond the Basics

Comparator

Also written: Comparators, comparing, comparingInt, thenComparing

A functional interface whose compare(a, b) orders two values from outside the type, so you can have many sort orders. Comparator.comparing(Product::name) builds one from a field.

Where the book teaches it

Related terms

ComparableMethod referenceLambda