This commit is contained in:
Looly
2022-12-27 17:41:52 +08:00
parent 803f1b313c
commit e645d741c7
2 changed files with 61 additions and 0 deletions

View File

@@ -46,6 +46,14 @@ public class IndexedComparator<T> implements Comparator<T> {
final int index1 = getOrder(o1);
final int index2 = getOrder(o2);
// 任意一个元素不在列表中
if(index1 == index2){
if(index1 < 0 || index1 == this.array.length){
// 任意一个元素不在列表中, 返回原顺序
return 1;
}
}
return Integer.compare(index1, index2);
}