Я использую Java 8 для группировки по данным. Но полученные результаты не упорядочены.
Map<GroupingKey, List<Object>> groupedResult = null;
        if (!CollectionUtils.isEmpty(groupByColumns)) {
            Map<String, Object> mapArr[] = new LinkedHashMap[mapList.size()];
            if (!CollectionUtils.isEmpty(mapList)) {
                int count = 0;
                for (LinkedHashMap<String, Object> map : mapList) {
                    mapArr[count++] = map;
                }
            }
            Stream<Map<String, Object>> people = Stream.of(mapArr);
            groupedResult = people
                    .collect(Collectors.groupingBy(p -> new GroupingKey(p, groupByColumns), Collectors.mapping((Map<String, Object> p) -> p, toList())));
public static class GroupingKey 
        public GroupingKey(Map<String, Object> map, List<String> cols) {
            keys = new ArrayList<>();
            for (String col : cols) {
                keys.add(map.get(col));
            }
        }
        // Add appropriate isEqual() ... you IDE should generate this
        @Override
        public boolean equals(Object obj) {
            if (obj == null) {
                return false;
            }
            if (getClass() != obj.getClass()) {
                return false;
            }
            final GroupingKey other = (GroupingKey) obj;
            if (!Objects.equals(this.keys, other.keys)) {
                return false;
            }
            return true;
        }
        @Override
        public int hashCode() {
            int hash = 7;
            hash = 37 * hash + Objects.hashCode(this.keys);
            return hash;
        }
        @Override
        public String toString() {
            return keys + "";
        }
        public ArrayList<Object> getKeys() {
            return keys;
        }
        public void setKeys(ArrayList<Object> keys) {
            this.keys = keys;
        }
    }
Здесь я использую свой класс groupingKey, с помощью которого я m динамически переходит из ux. Как получить эту группуByColumns в отсортированной форме?
