// Textbook fragment 08.02 /** Comparator for 2D points under the standard lexicographic order. */ public class Lexicographic implements java.util.Comparator { /** Compare two points */ public int compare(E a, E b) { if (a.getX() != b.getX()) return b.getX() - a.getX(); else return b.getY() - a.getY(); } } // Lexicographic automatically inherits an equals() method from Object