public function sortBy($sKey = '', $deep = 0) { if ($sKey) { self::$sortParam = $sKey; if (self::$sortParam != $this->groupKey) { if ($this->_hotels) { uasort($this->_hotels, 'HotelStack::compareHotelsByHotelsParams'); } elseif ($this->hotelStacks) { if ($deep != 0) { foreach ($this->hotelStacks as $i => $hotelStack) { $this->hotelStacks[$i]->sortBy($sKey, $deep - 1); } } //echo "sorting hotelStacks<br>"; try { uasort($this->hotelStacks, 'HotelStack::compareStacksByHotelsParams'); } catch (CException $e) { //echo "group: {$this->groupKey}"; print_r($this->hotelStacks); } } else { return false; } } } return $this; }