private int compareRank(Group rhs) {
        long diff = 0;
        for (int i = 0, m = orderByIdx.size(); (diff == 0) && (i < m); i++) {
            int rawIndex = orderByIdx.get(i);
            int index = ((rawIndex < 0) ? -rawIndex : rawIndex) - 1;
            diff = orderByExp.get(index).getResult().compareTo(rhs.orderByExp.get(index).getResult());
            diff = diff * rawIndex;
        }
        if (diff < 0) {
            return -1;
        }
        if (diff > 0) {
            return 1;
        }
        return -Double.compare(rank, rhs.rank);
    }
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