0
点赞
收藏
分享

微信扫一扫

Stream字符串按数字排序

惠特曼 2022-06-03 阅读 42

 

//对字符串数字排序
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)));
举报

相关推荐

0 条评论