addressbook
Class Person.CompareByZip

java.lang.Object
  extended by addressbook.Person.CompareByZip
All Implemented Interfaces:
java.util.Comparator<Person>
Enclosing class:
Person

public static class Person.CompareByZip
extends java.lang.Object
implements java.util.Comparator<Person>

Comparator for comparing two persons by order of zip code, with ties broken by name


Constructor Summary
Person.CompareByZip()
           
 
Method Summary
 int compare(Person person1, Person person2)
          Compare two Persons by zip, with ties broken by name
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Constructor Detail

Person.CompareByZip

public Person.CompareByZip()
Method Detail

compare

public int compare(Person person1,
                   Person person2)
Compare two Persons by zip, with ties broken by name

Specified by:
compare in interface java.util.Comparator<Person>
Parameters:
person1 - the first person
person2 - the second person
Returns:
a negative number if person1 belongs before person2 in order of zip with ties broken by name; 0 if they are equal on both name and zip; a positive number if person1 belongs after person2 in order of zip with ties broken by name.