public function testIntSort_with_two_key_desc() { $sorter = new ObjectSorter("prop1,prop2 desc"); for ($i = 0; $i < count($this->list); $i++) { $this->list[$i]->prop1 = bcmod($i, 10); } $ret = $sorter->sort($this->list); for ($i = 0; $i < count($ret) - 1; $i++) { $this->assertTrue(bccomp($ret[$i]->prop1, $ret[$i + 1]->prop1) >= 0); if ($ret[$i]->prop1 === $ret[$i]->prop2) { $this->assertTrue(bccomp($ret[$i]->prop2, $ret[$i + 1]->prop2) >= 0); } } }
private function sort_by_keys($list, $orderby) { $sorter = new ObjectSorter($orderby); $sorted_list = $sorter->sort($list); return $sorted_list; }