public static int compare(byte[] b1, int start1, int length1, byte[] b2,
      int start2, int length2) {

    int min = Math.min(length1, length2);

    for (int i = 0; i < min; i++) {
      if (b1[start1 + i] == b2[start2 + i]) {
        continue;
      }
      if (b1[start1 + i] < b2[start2 + i]) {
        return -1;
      } else {
        return 1;
      }
    }

    if (length1 < length2) {
      return -1;
    }
    if (length1 > length2) {
      return 1;
    }
    return 0;
  }
Returns -1 if the first byte sequence is lexicographically less than the
second; returns +1 if the second byte sequence is lexicographically less
than the first; otherwise return 0.
serde/src/java/org/apache/hadoop/hive/serde2/lazy/LazyUtils.java