import java.util.*;
/**
* @author lzy
* @Date 2019/5/9 17:17
* @Version 1.0
* @name 排序工具类
*/
public class SortUtils {
/**
* 功能描述:Map从大到小排序
* @param: [stringListMap] Map<String,List<T>>
* @return: java.util.List<java.util.Map.Entry<java.lang.String,org.apache.poi.ss.formula.functions.T>>
* @auther: lzy
* @date: 2019/5/9 17:32
* @param stringListMap
*/
public static <T> List<Map.Entry<String, T>> getmapDescSort(Map<String, T> stringListMap){
List<Map.Entry<String, T>> lists=new ArrayList<>();
lists.addAll(stringListMap.entrySet());
Collections.sort(lists,new Comparator<Map.Entry<String,T>>() {
@Override
public int compare(Map.Entry<String, T> o1, Map.Entry<String, T> o2) {
return o2.getKey().compareTo(o1.getKey());
}
});
return lists;
}
/**
* 功能描述:Map从小到大排序
* @param: [stringListMap] Map<String,List<T>>
* @return: java.util.List<java.util.Map.Entry<java.lang.String,org.apache.poi.ss.formula.functions.T>>
* @auther: lzy
* @date: 2019/5/9 17:31
*/
public static <T> List<Map.Entry<String, T>> getmapAscSort(Map<String,T> stringListMap){
List<Map.Entry<String, T>> lists=new ArrayList<>();
lists.addAll(stringListMap.entrySet());
Collections.sort(lists,new Comparator<Map.Entry<String,T>>() {
@Override
public int compare(Map.Entry<String, T> o1, Map.Entry<String, T> o2) {
return o1.getKey().compareTo(o2.getKey());
}
});
return lists;
}
public static void main(String[] args) {
}
}