FileDocCategorySizeDatePackage
PersonSorter.javaAPI DocExample660Sun Sep 11 17:34:14 BST 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;