April 05
Prde. Ismael H. F. Santos -  ismael@tecgraf.puc-rio.br                                                          2
Exemplo Ordenação – Comparator (cont)
npublic class EmpSort {
n   static final Comparator<Employee> SENIORITY_ORDER =  new    Comparator<Employee>() {
n         public int compare(Employee e1, Employee e2) {
n              return e2.hireDate().compareTo(e1.hireDate()); }
n     };
n     // Employee database
n    static final Collection<Employee> employees = ... ;
n    public static void main(String[] args) {
n         List<Employee>e = new ArrayList<Employee>(employees); 
n         Collections.sort(e, SENIORITY_ORDER); System.out.println(e);
n    }
n}