s-day04-Arrays工具类的排序功能介绍
This commit is contained in:
@@ -51,11 +51,11 @@ public class SortDemo12 {
|
||||
new Student("小王3", 17),
|
||||
new Student("小王4", 18),
|
||||
new Student("小王5", 16));
|
||||
|
||||
System.out.println(list);
|
||||
sortList(list, new Comparator<Student>() {
|
||||
@Override
|
||||
public int compare(Student o1, Student o2) {
|
||||
return o2.age - o1.age;
|
||||
return o1.age - o2.age;
|
||||
}
|
||||
});
|
||||
System.out.println(list);
|
||||
@@ -88,7 +88,7 @@ public class SortDemo12 {
|
||||
//交换
|
||||
T temp = arr.get(j);
|
||||
arr.set(j, arr.get(j+1));
|
||||
arr.set(j = 1, temp);
|
||||
arr.set(j + 1, temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user