/** @param args */ public static void main(String[] args) { log.info("Class Started to Execute*********"); BigDecimal bd = new BigDecimal(2.0); // TODO Auto-generated method stub Person p1 = new Person(20, "Kiran"); Person p2 = new Person(30, "Swe"); Person p3 = new Person(25, "WNal"); List<Person> list = new ArrayList<Person>(); list.add(p1); list.add(p2); list.add(p3); PersonNameComparator pname = new PersonNameComparator(); Collections.sort(list); Collections.sort(list, pname); log.info("Sortimg Completed>>..."); for (Person elem : list) { log.info("Person Details :: Id: " + elem.getPersonId() + " Name " + elem.getPersonName()); } }
@Override public int compare(Person p1, Person p2) { // TODO Auto-generated method stub return p1.getPersonName().compareTo(p2.getPersonName()); }