Here you can find the source of sortListByMapKey(List
public static void sortListByMapKey(List<Map<String, Object>> list)
//package com.java2s; //License from project: Apache License import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Map; public class Main { public static void sortListByMapKey(List<Map<String, Object>> list) { Collections.sort(list, new Comparator<Map<String, Object>>() { @Override//from w w w . j a v a2 s . c o m public int compare(Map<String, Object> o1, Map<String, Object> o2) { // TODO Auto-generated method stub String name = o1.get("key").toString(); String _name = o2.get("key").toString(); int n1 = name.length(), n2 = _name.length(); for (int i1 = 0, i2 = 0; i1 < n1 && i2 < n2; i1++, i2++) { char c1 = name.charAt(i1); char c2 = _name.charAt(i2); if (c1 != c2) { c1 = Character.toUpperCase(c1); c2 = Character.toUpperCase(c2); if (c1 != c2) { c1 = Character.toLowerCase(c1); c2 = Character.toLowerCase(c2); if (c1 != c2) { if (n1 == n2) { return (c1 - c2); } } } } } return n1 - n2; } }); } }