private Object getSubField(Object field, String key) {
        if (field instanceof Inspectable) {
            Inspector top = ((Inspectable)field).inspect();
            int firstDot = key.indexOf('.');
            if (firstDot > 0) {
                Inspector sub = top.field(key.substring(0, firstDot));
                if (sub.valid()) {
                    return getSubField(sub, key.substring(firstDot + 1));
                }
            }
            Inspector sub = top.field(key);
            if (sub.valid()) {
                return switch (sub.type()) {
                    case EMPTY -> null;
                    case BOOL -> (sub.asBool() ? Boolean.TRUE : Boolean.FALSE);
                    case LONG -> sub.asLong();
                    case DOUBLE -> sub.asDouble();
                    case STRING -> sub.asString();
                    default -> sub.toString();
                };
            }
        }
        // fallback value
        return field;
    }
Compares hits based on a sorting specification and values
stored in hit fields.0
<p>
When one of the hits has the requested property and the other
has not, the hit containing the property precedes the one
that does not.
<p>
There is no locale based sorting here, as the backend does
not do that either.

@return -1, 0, 1 if first should be sorted before, equal to or after second
container-search/src/main/java/com/yahoo/search/result/FieldComparator.java