List排序:?
考察的是Collection.sort()方法的使用

public class Test {
public static void main(String[] args) {
final List<Employee> employees = new ArrayList<Employee>();
employees.add(new Employee(3, "张三", -13001f));
employees.add(new Employee(32, "张三", -13001.1f));
employees.add(new Employee(31, "张三", 12999.6f));
Collections.sort(employees, new Comparator<Employee>() {
// compare返回正数,表示第一个对象比第二个对象大,返回负数表示第二个对象比第一个对象大
// o2-o1,是降序排列,o1-o2是升序排列
public int compare(Employee o1, Employee o2) {
return (int) (o1.getSalary() - o2.getSalary());
}
});
System.out.println(employees);
{
}
}
}