public static int compare(byte[] lhs, byte[] rhs) {
        int cmp = 0;
        for (int i = 0, len = Math.min(lhs.length, rhs.length); (i < len) && (cmp == 0); i++) {
            int a = lhs[i] & 0xFF;
            int b = rhs[i] & 0xFF;
            cmp = a - b;
        }
        if (cmp == 0) {
            cmp = lhs.length - rhs.length;
        }
        return cmp;
    }
Implements comparison of two byte arrays.

@param lhs the left-hand-side of the comparison
@param rhs the right-hand-side of the comparison
@return the result of comparing the two byte arrays
searchlib/src/main/java/com/yahoo/searchlib/aggregation/RawData.java