code: @SuppressWarnings("unchecked")
      public int compare(Subject a, Subject b) {
          int result = 0;
  
          Set<Attribute> setA = new TreeSet<Attribute>(ATTRIBUTE_COMPARATOR);
          setA.addAll(a.getAttributesAsList());
  
          Set<Attribute> setB = new TreeSet<Attribute>(ATTRIBUTE_COMPARATOR);
          setB.addAll(b.getAttributesAsList());
  
          Iterator<Attribute> iterA = setA.iterator();
          Iterator<Attribute> iterB = setB.iterator();
          while (iterA.hasNext() && iterB.hasNext()) {
              Attribute attrA = iterA.next();
              Attribute attrB = iterB.next();
              result = ATTRIBUTE_COMPARATOR.compare(attrA, attrB);
  
              if (result != 0) {
                  return result;
              }
          }
  
          result = setA.size() - setB.size();
  
          return result;
      }
docs: /*
  (non-Javadoc)
  @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)