修复IndexedComparator导致的数据错乱问题(ExcelWriter使用部分别名导致字段丢失)

This commit is contained in:
Looly
2022-12-27 19:59:35 +08:00
parent 05c32a8f46
commit 1e11bd5da5
2 changed files with 11 additions and 0 deletions

View File

@@ -46,6 +46,16 @@ 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 0;
}
return Integer.compare(index1, index2);
}