public static Map<String, List<TPricePpiBaseWeight>> sortMapByKey(Map<String, List<TPricePpiBaseWeight>> map) { if (map == null || map.isEmpty()) { return null; } Map<String, List<TPricePpiBaseWeight>> sortMap = new TreeMap<String, List<TPricePpiBaseWeight>>( new MapKeyComparator()); sortMap.putAll(map); return sortMap; }
import java.util.Comparator; public class MapKeyComparator implements Comparator<String> { @Override public int compare(String str1, String str2) { return str1.compareTo(str2); } }
标签:map,null,return,Map,sortMap,key,排序,public From: https://www.cnblogs.com/chenTo/p/17713912.html