0

我有一个 Java 8 中的 SomeClass 列表,我想对列表进行排序。

举这个例子

class Student {
   String name; 
   int age; 
   int id; 
   public String getName() {
      return name; 
   } 
   public int getAge() { 
      return age; 
   } 
   public int getId() { 
      return id; 
   } 
   Student(String n, int a, int i){ 
      name = n; 
      age = a; 
      id = i; 
   } 
   @Override public String toString() {     
      return ("Student[ "+"Name:"+this.getName()+             
              " Age: "+ this.getAge() +                     
              " Id: "+ this.getId()+"]"); 
   }
}

名单

  List<Student> studentlist = new ArrayList<Student>();
  studentlist.add(new Student("Jon", 22, 1001)); 
  studentlist.add(new Student("Steve", 19, 1003)); 
  studentlist.add(new Student("Kevin", 23, 1005)); 
  studentlist.add(new Student("Ron", 20, 1010)); 
  studentlist.add(new Student("Lucy", 18, 1111));

相反的顺序

studentlist.sort(Comparator.comparingInt(Student:: getAge).reversed());

但是,用RadixSort,订购 120000 怎么样BucketSort

(在我看来这是不可能的,但我需要保证安全)是否可以使用 RadixSort、BucketSort 实现 Comparator?

如果是,如何?

4

0 回答 0