code: @SuppressWarnings({ "rawtypes", "unchecked" })
      @Override
      public int compare(WritableComparable a, WritableComparable b) {
          if (a instanceof Key && b instanceof Key) {
              Comparable oneIdentifier = Key.class.cast(a).identifier();
              Comparable otherIdentifier = Key.class.cast(b).identifier();
  
              int identifier = oneIdentifier.compareTo(otherIdentifier);
              if (identifier != 0) {
                  return identifier;
              }
  
              Map<Integer, SortWritable> oneSort = Key.class.cast(a).getSort();
              Map<Integer, SortWritable> otherSort = Key.class.cast(b).getSort();
              if (oneSort.size() != otherSort.size()) {
                  return -1;
              }
  
              for (Entry<Integer, SortWritable> entry : oneSort.entrySet()) {
                  int priority = entry.getKey();
                  SortWritable one = entry.getValue();
                  SortWritable other = otherSort.get(priority);
  
                  if (ObjectUtil.typeCompareTo(one.getValue(), other.getValue()) != 0) {
                      return -1;
                  }
  
                  int cmpare = one.compareTo(other);
                  if (cmpare != 0) {
                      if (one.getSort().get() == Record.SORT_LOWER) {
                          return cmpare;
                      } else {
                          return -cmpare;
                      }
                  }
              }
  
              return 0;
          }
  
          return super.compare(a, b);
      }
docs: {@inheritDoc}