key升序
区分大小写
public Map<String, String> sortAsc(Map<String, String> parameters){
Map<String, String> treeMap = new TreeMap<String, String>(new Comparator<String>() {
@Override
public int compare(String obj1, String obj2) {
return obj1.compareTo(obj2);
}
});
treeMap.putAll(parameters);
return treeMap;
}
不区分大小写
public Map<String, String> sortAscIgnore(Map<String, String> parameters){
Map<String, String> treeMap = new TreeMap<String, String>(new Comparator<String>() {
@Override
public int compare(String obj1, String obj2) {
return obj1.toLowerCase().compareTo(obj2.toLowerCase());
}
});
treeMap.putAll(parameters);
return treeMap;
}