protected function sortProperty($a, $b) {
    $property = $this->sortProperty;
    $parent = $this->sortParent;
    if (isset($parent)
        && (isset($a->$parent->$property) || isset($b->$parent->$property))) {
      if (!$this->sortCaseSensitive
          && is_string($a->$parent->$property)
          && is_string($b->$parent->$property)) {
        $aprop = strtoupper($a->$parent->$property);
        $bprop = strtoupper($b->$parent->$property);
        if ($aprop > $bprop) {
          return 1;
        }
        if ($aprop < $bprop) {
          return -1;
        }
      } else {
        if ($a->$parent->$property > $b->$parent->$property) {
          return 1;
        }
        if ($a->$parent->$property < $b->$parent->$property) {
          return -1;
        }
      }
    }
    // If they have the same parent, order them by their own property.
    if (!$this->sortCaseSensitive
        && is_string($a->$property)
        && is_string($b->$property)) {
      $aprop = strtoupper($a->$property);
      $bprop = strtoupper($b->$property);
      if ($aprop > $bprop) {
        return 1;
      }
      if ($aprop < $bprop) {
        return -1;
      }
    } else {
      if ($a->$property > $b->$property) {
        return 1;
      }
      if ($a->$property < $b->$property) {
        return -1;
      }
    }
    return 0;
  }