private <T> T getAnnotation(OperatorNode<?> ast, String key, Class<T> expectedClass, T defaultValue,
                                String description, boolean considerParents) {
        Object value = ast.getAnnotation(key);
        for (Iterator<OperatorNode<?>> i = annotationStack.iterator(); value == null
                                                                       && considerParents && i.hasNext();) {
            OperatorNode<?> node = i.next();
            if (node.getOperator() == ExpressionOperator.VARREF) {
                Preconditions.checkState(userQuery != null,
                                         "properties must be available when trying to fetch user input");
                value = userQuery.properties().getString(ast.getArgument(0, String.class));
            }
            else {
                value = node.getAnnotation(key);
            }
        }
        if (value == null) return defaultValue;
        Preconditions.checkArgument(expectedClass.isInstance(value),
                                   "Expected %s for annotation '%s' (%s), got %s.",
                                    expectedClass.getName(), key, description, value.getClass().getName());
        return expectedClass.cast(value);
    }
The sorting specified in the YQL+ query last parsed.

@return a Sorting instance or null
container-search/src/main/java/com/yahoo/search/yql/YqlParser.java