public static void main(String[] args) {
// TODO 自动生成的方法存根
Scanner sc=new Scanner(System.in) ;
while(sc.hasNext()) {
int n=sc.nextInt();
Student[] arr = new Student[n];
for (int i = 0; i < n; i++) arr[i] = new Student(sc.next(),sc.nextInt(),sc.nextInt());
Arrays.sort(arr);
for (Student student : arr) System.out.println(student);
}
}
static class Student implements Comparable<Student>{
String name;
Integer age;
Integer score;
public Student(String name, Integer age, Integer score) {
super();
this.name = name;
this.age = age;
this.score = score;
}
@Override
public String toString() {
return name + " " + age + " " + score ;
}
public int compareTo(Student o) {
if (this.score.compareTo(o.score)==0){
if (this.name.compareTo(o.name)==0) return this.age.compareTo(o.age);
else return this.name.compareTo(o.name);
}else return this.score.compareTo(o.score);
}
}
成绩排序--按成绩、名字、年龄
最新推荐文章于 2024-11-03 11:01:20 发布