예제 #1
1
 /**
  * Compares this object with the specified object for order. Returns a negative integer, zero, or a positive
  * integer as this object is less than, equal to, or greater than the specified object.
  *
  * The implementor must ensure sgn(x.compareTo(y)) == -sgn(y.compareTo(x)) for all x and y.
  *
  * @param Comparable $b
  * @return int
  */
 public function compareTo(Comparable $b)
 {
     return strcmp($this->attr1, $b->getAttr1());
 }
예제 #2
1
 /**
  * Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first
  * argument is less than, equal to, or greater than the second.
  *
  * @param Comparable $a
  * @param Comparable $b
  * @return int
  */
 public function compare(Comparable $a, Comparable $b)
 {
     return array_search($a->getAttr1(), $this->customOrder) >= array_search($b->getAttr1(), $this->customOrder) ? 1 : -1;
 }