Collection<OrderField<?>> createOrderFields(final BaseCriteria criteria,
                                                final Map<String, Field<?>> additionalFieldMappings) {

        final Map<String, Field<?>> nameToFieldMap;
        if (additionalFieldMappings != null) {
            nameToFieldMap = new HashMap<>(SORT_FIELD_NAME_TO_FIELD_MAP);
            nameToFieldMap.putAll(additionalFieldMappings);
        } else {
            nameToFieldMap = SORT_FIELD_NAME_TO_FIELD_MAP;
        }

        final List<CriteriaFieldSort> sortList = NullSafe.mutableList(
                NullSafe.get(criteria, BaseCriteria::getSortList));
        if (sortList.isEmpty()) {
            return Collections.singleton(DEFAULT_SORT_FIELD);
        }

        final ArrayList<OrderField<?>> sortFields = sortList.stream()
                .map(sort -> {
                    Field<?> field = nameToFieldMap.get(sort.getId());
                    if (field == null) {
                        field = DEFAULT_SORT_FIELD;
                    }
                    return asOrderField(field, sort.isDesc());
                })
                .collect(Collectors.toCollection(ArrayList::new));

        // Add displayName as a secondary sort
        if (!sortFields.contains(DEFAULT_SORT_FIELD)) {
            final OrderField<?> orderField = asOrderField(DEFAULT_SORT_FIELD, false);
            sortFields.add(orderField);
        }
        LOGGER.debug("createOrderFields - sortList: {}, sortFields: {}", sortList, sortFields);
        return sortFields;
    }
@param additionalFieldMappings Any additional field name to {@link Field} mappings. Can be null.
stroom-security/stroom-security-impl-db/src/main/java/stroom/security/impl/db/UserDaoImpl.java