FileDocCategorySizeDatePackage
PersonSorter.javaAPI DocExample1840Thu Dec 15 21:42:36 GMT 2005com.oreilly.jent.people

PersonSorter

public class PersonSorter extends Object implements Comparator
A comparator that allows a collection of Person beans to be sorted according to last name, first name.
author
Jim Farley

Fields Summary
Constructors Summary
public PersonSorter()

Methods Summary
public intcompare(java.lang.Object o1, java.lang.Object o2)

        Person p1 = (Person)o1;
        Person p2 = (Person)o2;
        int ncomp = p1.getLastName().compareTo(p2.getLastName());
        // If the last names are equal, check the first names
        if (ncomp == 0) {
            ncomp = p1.getFirstName().compareTo(p2.getFirstName());
        }
        return ncomp;