public function compare(PersistentObject $a, PersistentObject $b) {
    // we compare for each criteria and sum the results for $a, $b
    // afterwards we compare the sums and return -1,0,1 appropriate
    $sumA = 0;
    $sumB = 0;
    $maxWeight = sizeOf($this->sortCriteria);
    $i = 0;
    foreach ($this->sortCriteria as $criteria => $sortType) {
      $weightedValue = ($maxWeight-$i)*($maxWeight-$i);
      $aGreaterB = 0;
      // sort by id
      if ($criteria == self::ATTRIB_OID) {
        if ($a->getOID() != $b->getOID()) {
          ($a->getOID() > $b->getOID()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by type
      else if ($criteria == self::ATTRIB_TYPE) {
        if ($a->getType() != $b->getType()) {
          ($a->getType() > $b->getType()) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by value
      else if($a->getValue($criteria) != null || $b->getValue($criteria) != null) {
        $aValue = strToLower($a->getValue($criteria));
        $bValue = strToLower($b->getValue($criteria));
        if ($aValue != $bValue) {
          ($aValue > $bValue) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // sort by property
      else if($a->getProperty($criteria) != null || $b->getProperty($criteria) != null) {
        $aProperty = strToLower($a->getProperty($criteria));
        $bProperty = strToLower($b->getProperty($criteria));
        if ($aProperty != $bProperty) {
          ($aProperty > $bProperty) ? $aGreaterB = 1 : $aGreaterB = -1;
        }
      }
      // calculate result of current criteria depending on current sorttype
      if ($sortType == self::SORTTYPE_ASC) {
        if ($aGreaterB == 1) { $sumA += $weightedValue; }
        else if ($aGreaterB == -1) { $sumB += $weightedValue; }
      }
      else if ($sortType == self::SORTTYPE_DESC) {
        if ($aGreaterB == 1) { $sumB += $weightedValue; }
        else if ($aGreaterB == -1) { $sumA += $weightedValue; }
      }
      else {
        throw new IllegalArgumentException("Unknown SORTTYPE.");
      }
      $i++;
    }
    if ($sumA == $sumB) { return 0; }
    return ($sumA > $sumB) ? 1 : -1;
  }