code: public int compareTo(Weight anotherWeight) {
          boolean wIsInfinity = anotherWeight.isInfinity;
          boolean wPosOrNeg = anotherWeight.posOrNeg;
  
          if (isInfinity && wIsInfinity
                  && ((posOrNeg && wPosOrNeg) || (!posOrNeg && !wPosOrNeg))) {
              return 0;
          } else if ((isInfinity && posOrNeg) || (wIsInfinity && !wPosOrNeg)) {
              return 1;
          } else if ((isInfinity && !posOrNeg) || (wIsInfinity && wPosOrNeg)) {
              return -1;
          } else if (val < anotherWeight.val) {
              return -1;
          } else if (val > anotherWeight.val) {
              return 1;
          } else {
              return 0;
          }
      }
docs: Compares two <code>Weight</code> objects numerically.
  
  @param anotherWeight
  the <code>Weight</code> to be compared.
  @return the value <code>0</code> if this <code>Weight</code> is equal
  to the argument <code>Weight</code>; a value less than
  <code>0</code> if this <code>Weight</code> is numerically
  less than the argument </code>Weight</code>; and a value
  greater than <code>0</code> if this <code>Weight</code> is
  numerically greater than the argument <code>Weight</code>
  (signed comparison).