fix sort bug

This commit is contained in:
Looly
2021-08-19 14:36:07 +08:00
parent 9d8f00e049
commit dbc4fd62ce
2 changed files with 4 additions and 6 deletions

View File

@@ -791,18 +791,15 @@ public class MapUtil {
return null;
}
TreeMap<K, V> result;
if (map instanceof TreeMap) {
// 已经是可排序Map此时只有比较器一致才返回原map
result = (TreeMap<K, V>) map;
TreeMap<K, V> result = (TreeMap<K, V>) map;
if (null == comparator || comparator.equals(result.comparator())) {
return result;
}
} else {
result = newTreeMap(map, comparator);
}
return result;
return newTreeMap(map, comparator);
}
/**