private static void doOrderedPut(final Type type1,
                                     final Type type2,
                                     final ValComparatorFactory comparatorFactory) {
        // Little check to stop us accidentally defining a comparator for a pair twice, but
        // with a different comparator each time
        final ValComparatorFactory existingComparatorFactory = getComparatorFactory(type1, type2)
                .orElse(null);
        if (existingComparatorFactory != null
            && !Objects.equals(existingComparatorFactory, comparatorFactory)) {
            throw new IllegalArgumentException(LogUtil.message(
                    "Trying to put a different comparator factory for types {} & {}",
                    type1, type2));
        }

        final Map<Type, ValComparatorFactory> subMap = COMPARATOR_NESTED_MAP.computeIfAbsent(type1,
                k -> new EnumMap<>(Type.class));
        subMap.put(type2, comparatorFactory);
    }
type1 and type2 can be in any order
stroom-query/stroom-query-language/src/main/java/stroom/query/language/functions/ValComparators.java