Stream字符串按数字排序

 

//对字符串数字排序
Stream.of("123", "321", "132","312").sorted(Comparator.comparingInt(Integer::parseInt))
// 对Object属性排序
Stream.of(
new Exception("13"),
new Exception("1"),
new Exception("21"),
new Exception("3")
).sorted(Comparator.comparing(Exception::getMessage, Comparator.comparingInt(Integer::parseInt)));

 

posted @ 2021-07-15 14:28  南北12345678  阅读(1516)  评论(0编辑  收藏  举报