JDK8 集合排序 xxxList.stream.sorted(...)

Posted 微风--轻许--

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JDK8 集合排序 xxxList.stream.sorted(...)相关的知识,希望对你有一定的参考价值。

前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家。点击跳转到教程。 

# 默认
list.stream().sorted() 
list.stream().sorted(Comparator.reverseOrder()) 

# 按字段排序
xxxList.stream().sorted(Comparator.comparing(XxxModel::getData_time));
# 倒序
xxList.stream().sorted(Comparator.comparing(XxxModel::getData_time).reversed());

 

以上是关于JDK8 集合排序 xxxList.stream.sorted(...)的主要内容,如果未能解决你的问题,请参考以下文章