List<Map<String, String>> 多字段排序
作者:互联网
页面传入的多个排序字段
排序字段
public class ReFormSort { //"列名" private String columnEname; //"ASC升序,DESC降序" private String sort; }
代码里进行多字段排序
List<Map<String, String>> content = formDataService.searchFormData(paras); List<ReFormSort> sorts = paras.getSorts(); //多个排序字段 for (int i = 0; i < sorts.size(); i++) { String columnEname = sorts.get(i).getColumnEname(); if (!StringUtils.isEmpty(sorts.get(i).getColumnEname()) && "asc".equals(sorts.get(i).getSort())) { content.sort(Comparator.comparing((Map<String, String> h) -> (h.get(columnEname)))); } if (!StringUtils.isEmpty(sorts.get(i).getColumnEname()) && "desc".equals(sorts.get(i).getSort())) { content.sort(Comparator.comparing((Map<String, String> h) -> (h.get(columnEname))).reversed()); } }
传送门 :->
标签:getColumnEname,String,get,List,columnEname,sorts,排序,多字段 来源: https://www.cnblogs.com/JonaLin/p/14636546.html