@Override
    public Group clone() {
        Group obj = (Group)super.clone();
        if (id != null) {
            obj.id = (ResultNode)id.clone();
        }

        if ( ! aggregationResults.isEmpty() ) {
            AggregationResult [] results = new AggregationResult[aggregationResults.size()];
            int i = 0;
            for (AggregationResult result : aggregationResults) {
                results[i++] = result.clone();
            }
            obj.aggregationResults = List.of(results);
        }
        obj.orderByIdx = List.copyOf(orderByIdx);
        if ( ! orderByExp.isEmpty()) {
            obj.orderByExp = new ArrayList<>();
            RefResolver resolver = new RefResolver(obj.aggregationResults);
            ExpressionNode[] orderBy = new ExpressionNode[orderByExp.size()];
            int i = 0;
            for (ExpressionNode exp : orderByExp) {
                exp = exp.clone();
                exp.select(REF_LOCATOR, resolver);
                orderBy[i++] = exp;
            }
            obj.orderByExp = List.of(orderBy);
            obj.aggregationResults = resolver.results;
        }
        if ( ! children.isEmpty() ) {
            Group [] groups = new Group[children.size()];
            int i = 0;
            for (Group child : children) {
                groups[i++] = child.clone();
            }
            obj.children = List.of(groups);
        }
        return obj;
    }
Adds an order-by expression to this group. If the expression is an AggregationResult, it will be added to the
list of this group's AggregationResults, and a reference to that expression is added instead. If the
AggregationResult is already present, a reference to THAT result is created instead.

@param exp the result to add
@param asc true to sort ascending, false to sort descending
@return this, to allow chaining
searchlib/src/main/java/com/yahoo/searchlib/aggregation/Group.java