Note 7.17.5. Java Note.
In line 20 of Listing 7.17.4, we call the sort method with two parameters. The first is the collection to sort; the second is a comparator, a class that gives the criteria for determining sorting order. A comparator implements a
compare
method that compares its two parameters. It returns a negative value if the first object is “less than” the second, zero if they are equal, and positive if the first object is “greater than” the second. Listing 7.17.6 shows the two comparators which we have added to the Vertex.java
file. These are nested classes.