Yes, you can use Collections.sort()
You need your Employee class to implement the Comparable interface.
http://download.oracle.com/javase/6/docs/api/java/lang/Comparable.html
In your compareTo() method, you compare the salary of the current object with the database of the object.
Edit:
Another option you have if you do not want this comparison by default to create a Comparator object and use the second form -> Collections.sort(List, Comparator);
It will look like this:
class SalaryComparator implements Comparator<Employee> { public int compare(Employee e1, Employee e2) { if (e1.getSalary() > e2.getSalary()) return 1; else if (e1.getSalary() < e2.getSalary()) return -1; else return 0; } }
Now you can do: Collections.sort(myEmployeeList, new SalaryComparator());
source share