java8两个字段进行排序问题

1
2
3
4
5
6
7
8
           <br>//这个解决问题<br>    Comparator<Anjianxinxi> getLianriqi = Comparator.comparing(Anjianxinxi::getLianriqi).reversed();
                Comparator<Anjianxinxi> getCaiChanLastTime = Comparator.comparing(Anjianxinxi::getCaiChanLastTime).reversed();
                records.sort(getLianriqi.thenComparing(getCaiChanLastTime));
//这个单个好使,组合不好使,不明白咋回事
//                records.stream()
//                        .sorted(Comparator.comparing(Anjianxinxi::getLianriqi).reversed().thenComparing(Anjianxinxi::getCaiChanLastTime).reversed())
//                        .collect(Collectors.toList());
             //   records.sort(Comparator.comparing(Anjianxinxi::getLianriqi).reversed().thenComparing(Anjianxinxi::getCaiChanLastTime).reversed());

  记录一下最后解决是这样的。

 

posted @   三号小玩家  阅读(2326)  评论(1编辑  收藏  举报
编辑推荐:
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
· C++代码改造为UTF-8编码问题的总结
阅读排行:
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
Title
三号小玩家的 Mail: 17612457115@163.com, 联系QQ: 1359720840 微信: QQ1359720840

喜欢请打赏

扫描二维码打赏

支付宝打赏

点击右上角即可分享
微信分享提示