コード例 #1
0
ファイル: Contest.php プロジェクト: creat2012/hustoj_official
 public function standing()
 {
     $solutions = $this->solutions();
     /* @var $data Model_Team[] */
     $data = array();
     $start_time = strtotime($this->start_time);
     foreach ($solutions as $item) {
         if (array_key_exists($item->user_id, $data)) {
             $team = $data[$item->user_id];
             $team->add($item->num, strtotime($item->in_date) - $start_time, $item->result);
         } else {
             $team = new Model_Team();
             $team->user_id = $item->user_id;
             $team->add($item->num, strtotime($item->in_date) - $start_time, $item->result);
             $data[$item->user_id] = $team;
         }
     }
     usort($data, function ($a, $b) {
         if ($a->solved > $b->solved) {
             return false;
         }
         if ($a->solved == $b->solved) {
             if ($a->time < $b->time) {
                 return false;
             }
         }
         return true;
     });
     return $data;
 }