import java.util.Comparator; /* An instance of this class defines an ordering on states in the USa ** (as represented by objects of the StateInUSa class) according to ** their names, using the standard ordering on Strings in Java. ** ** Author: R. McCloskey ** Date: April 2026 */ public class CompareByName implements Comparator { /* According to whether the name of stateA is less than, equal to, ** or greater than, respectively, that of stateB (with respect to ** lexicographic ordering), returns either a negative number, zero, ** or a positive number, respectively. Note that this ordering is ** consistent with String's compareTo() method. */ public int compare(StateInUSA stateA, StateInUSA stateB) { return stateA.nameOf().compareTo(stateB.nameOf()); } }