- 根据orderList顺序排序,orderList不存在的元素放置在targetList最后面
private static void sort1(List<String> targetList, List<String> orderList) {
targetList.sort(((o1, o2) -> {
int io1 = orderList.indexOf(o1);
int io2 = orderList.indexOf(o2);
if (io1 != -1) {
io1 = targetList.size() - io1;
}
if (io2 != -1) {
io2 = targetList.size() - io2;
}
return io2 - io1;
}));
}
private static void sort1(List<实体> targetList, List<String> orderList) {
targetList.sort(((o1, o2) -> {
int io1 = orderList.indexOf(o1.get出targetList与orderList相同的key);
int io2 = orderList.indexOf(o2.get出targetList与orderList相同的key;
if (io1 != -1) {
io1 = targetList.size() - io1;
}
if (io2 != -1) {
io2 = targetList.size() - io2;
}
return io2 - io1;
}));
}
- 根据orderList顺序排序,orderList不存在的元素放置在targetList最前面
private static void sort2(List<String> targetList, List<String> orderList) {
targetList.sort(((o1, o2) -> {
int io1 = orderList.indexOf(o1);
int io2 = orderList.indexOf(o2);
return io1 - io2;
}));
}
private static void sort2( List<实体> targetList, List<String> orderList) {
targetList.sort(((o1, o2) -> {
int io1 = orderList.indexOf(o1.get出targetList与orderList相同的key);
int io2 = orderList.indexOf(o2.get出targetList与orderList相同的key);
return io1 - io2;
}));
}
```