code: protected int compareKeysPartially(byte[] key1, byte[] key2) {
          int length = Math.min(key1.length, key2.length);
          for (int i=0; i<length; i++) {
              int a1 = key1[i];
              int a2 = key2[i];
              if (a1 != a2) {
                  return (a1 & 0xff) - (a2 & 0xff);
              }
          }
          return 0;
      }
docs: Returns {@literal <0} if key1 is less, 0 if equal (at least partially),
  {@literal >0} if key1 is greater.