added getting a ranking of players

This commit is contained in:
Jeroen De Meerleer 2019-02-06 17:24:10 +01:00
parent 82370b25d7
commit e367e8929b
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -52,4 +52,25 @@ class Tournament extends TournamentModel
$this->setRounds($newArray); $this->setRounds($newArray);
} }
/**
* @return array
*/
public function getRanking()
{
$players = $this->getPlayers();
$rankingsArray = array();
foreach ($players as $player) {
$rankingsArray[$player->getPoints()] = $player;
}
$rankingsArray = ksort($finalArray);
$finalArray = array();
$i = 0;
foreach ($rankingsArray as $ranking) {
$finalArray[$i] = $ranking;
$i++;
}
return $finalArray();
}
} }