List
list.add(2);
list.add(3);
list.add(1);
//降序[3, 2, 1]
list.sort((o1, o2) -> {
if (o1 < o2) {
return 1;
} else {
return -1;
}
});
System.out.println(list);
//升序[1, 2, 3]
list.sort((o1,o2)->1*o1.compareTo(o2));
System.out.println(list);
//降序[3, 2, 1]
list.sort((o1,o2)->-1*o1.compareTo(o2));
System.out.println(list);