Skip to content

Instantly share code, notes, and snippets.

@sreelallalu
Created January 3, 2018 04:59
Show Gist options
  • Save sreelallalu/0c9507e8d0c9cfd32c851d3db0f6f102 to your computer and use it in GitHub Desktop.
Save sreelallalu/0c9507e8d0c9cfd32c851d3db0f6f102 to your computer and use it in GitHub Desktop.
Collection sorting List
public static List<Employee> getEmployeeListSortedByName() {
final List<Employee> employeeList = getEmployeeList();
Collections.sort(employeeList, new Comparator<Employee>() {
@Override
public int compare(Employee a1, Employee a2) {
return a1.getName().compareTo(a2.getName());
}
});
return employeeList;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment