当前位置:网站首页>如何让一个list根据另一个list的顺序排序
如何让一个list根据另一个list的顺序排序
2022-06-23 17:43:00 【热爱生活的猴子】
直接上代码:
//首先要保证List<User> users和List<Long> userIds
public void setListOrder(List<User> users, List<Long> userIds){
users.sort((o1,o2) -> {
int io1 = ids.indexOf(o1.getId());
int io2 = ids.indexOf(o2.getId());
if(io1 != -1){
io1 = users.size() - io1;
}
if(io2 != -1){
io2 = users.size() - io2;
}
return io2-io1;
});
}边栏推荐
猜你喜欢

可编程的,协议独立的软件交换机(论文阅读)

STM32(八)------- PWM输出

Yapi installation

QML类型:Loader

QT implements a rule-based machinetranslation system course paper + assignment + project source code

CSDN salary increase secret script: Jenkins integrated allure test report complete tutorial

Practical circuit analysis 3

【翻译】一种减小运动伪影的新方法基于AS-LMS自适应滤波器的PPG信号

leetcode刷题:哈希表01 (有效的字母异位词)

【Wwise】Wwise嵌入Unity后打包出现没有声音问题
随机推荐
Improving efficiency or increasing costs, how should developers understand pair programming?
[Wwise] there is no sound problem after Wwise is embedded in unity and packaged
第十三届蓝桥杯单片机国赛真题
js25题目
凸优化笔记
Will programmers become very professional in the future?
Why create a public OKR?
leetcode刷题:哈希表05 (四数相加 II)
Rancher2.6 new monitoring QuickStart
VirtP4笔记
Latex compiled successfully but could not be output to PDF
After the Computer College changed its examination, the College of Cyberspace Security also changed its examination! Nanjing University of technology computer postgraduate entrance examination
Thesis reading (53):universal advantageous perturbations
Leetcode: hash table 07 (sum of three numbers)
Simpledateformat has thread safety problems in multi-threaded environments.
2022年升降机司机考试题模拟考试平台操作
Self training multi sequence learning with transformer for weakly supervised video animation
The battlefield of live broadcast e-commerce is not in the live broadcast room
Video anomaly detection data set (shanghaitech)
QML type: Loader