List<Map<String, Object>> list = [["loc": "A-02-01","code":"asdf"],["loc": "B-01-01","code":"ff"], ["loc": "B-01-01","code":"23"], ["loc": "A-01-04","code":"ghg"]] list.sort{a,b-> if (a.loc < b.loc) { return -1 }else if (a.loc == b.loc) { a.code.compareTo(b.code) } else { return 1 } }
Result: [[loc:A-01-04, code:ghg], [loc:A-02-01, code:asdf], [loc:B-01-01, code:23], [loc:B-01-01, code:ff]]