1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
private function compare_asc($a, $b){ $value1 = $a->tx_price; $value2 = $b->tx_price; if($value1 == $value2){ return 0; }elseif($value1 < $value2){ return -1; }else{ return 1; } } private function compare_desc($a, $b){ if($a == $b){ return 0; } if($a->tx_price > $b->tx_price){ return -1; }else{ return 1; } } private function collection2array($collection){ $arr = []; foreach ($collection as $key => $item) { $arr[] = $item; } return $arr; } private function compare_string($a, $b){ $v = strcmp($a->BEDNO, $b->BEDNO); if($v == 0){ return 0; } if($v > 0){ return 1; }else{ return -1; } } public function test(){ $future_id = 10; //$price = FutureM::get_price($future_id); $price = FutureM::get_price_by_id(19009); //logg($price); //logg($price); $buy_prices = ReportM::future5_buy_prices($price); $buy_prices = $this->collection2array($buy_prices); usort($buy_prices, array($this,'compare_desc')); logg($buy_prices); } |