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-04-07 14:49  悠哉日长大王  阅读(2743)  评论(0编辑  收藏  举报