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)));

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM