/**
* 排序 按小写a-z排序(大写A-Z也按小写排序)
* @param map
* @return
*/
public static LinkedHashMap<String, Object> alterPosit(Map<String, Object> map) {
TreeMap<String, Object> mapNew = new TreeMap<>();
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
mapNew.put(key.toLowerCase(), map.get(key));
}
LinkedHashMap<String, Object> lastMap = new LinkedHashMap<>();//倒序
for(String key : mapNew.keySet()) {
for(String trKey : map.keySet()) {
if(key.equalsIgnoreCase(trKey)) {
lastMap.put(trKey, map.get(trKey));
}
}
}
return lastMap;
}
提醒:如果按ASCII从小到大排序直接用TreeMap()集合。(该集合会区分大小写)。