@Override
    protected void onSerialize(Serializer buf) {
        super.onSerialize(buf);
        serializeOptional(buf, id);
        buf.putDouble(null, rank);
        int sz = orderByIdx.size();
        buf.putInt(null, sz);
        for (Integer index : orderByIdx) {
            buf.putInt(null, index);
        }
        int numResults = aggregationResults.size();
        buf.putInt(null, numResults);
        for (AggregationResult a : aggregationResults) {
            serializeOptional(buf, a);
        }
        int numExpressionResults = orderByExp.size();
        buf.putInt(null, numExpressionResults);
        for (ExpressionNode e : orderByExp) {
            serializeOptional(buf, e);
        }
        int numGroups = children.size();
        buf.putInt(null, numGroups);
        for (Group g : children) {
            g.serializeWithId(buf);
        }
        buf.putInt(null, tag);
    }
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