import java.util.*;
/**
*
* @author shirley
* @date 2019/9/4
*/
public class Main {
public static void main(String[] args) {
List<Integer> list = Arrays.asList(4,2,7,3,6);
Collections.sort(list,(o1,o2)->{
if(o1<o2){
return -1;
}
if(o1>o2){
return 1;
}
return 0;
});
System.out.println(list);
}
}
结果:[2, 3, 4, 6, 7]
来源:https://blog.csdn.net/weixin_44683617/article/details/100540746