code: private int compareKinds(Kind kind1, Kind kind2) {
      if (kind1 == Kind.LENGTH && kind2 == Kind.DATA) {
        return -1;
      }
  
      if (kind1 == Kind.DATA && kind2 == Kind.LENGTH) {
        return 1;
      }
  
      return kind1.compareTo(kind2);
    }
docs: stuck with it, this is just a hack to work around that.