packagecomparator.example;
importjava.util.ArrayList;
importjava.util.Collections;
publicclassComparatorExample {
publicstaticvoidmain(String[] args){
Employee1emp1 = newEmployee1("Akash",35,1500);
Employee1emp2 = newEmployee1("SunSHun",25,3500);
Employee1emp3 = newEmployee1("Tim",29,3000);
Employee1emp4 = newEmployee1("Keerthana",26,500);
Employee1emp5 = newEmployee1("Naverick",38,4000);
//Create a Array listArrayList<Employee1> arrayList = newArrayList<Employee1>();
arrayList.add(emp1);
arrayList.add(emp2);
arrayList.add(emp3);
arrayList.add(emp4);
arrayList.add(emp5);
//Sort the array, by default based on age as mentioned in the Employee Class using ComparableCollections.sort(arrayList);
System.out.println("Sorting based on Age: " + arrayList.toString());
//Sort based on Salary ComparatorCollections.sort(arrayList,newEmployeeSalaryComparator());
System.out.println("Sorting based on Salary as: " + arrayList.toString());
}
}