mirror of
https://github.com/JeroenED/libpairtwo.git
synced 2024-11-21 22:17:41 +01:00
Better sorting function
This commit is contained in:
parent
c9d5407f0c
commit
93125bb79c
@ -58,19 +58,14 @@ class Tournament extends TournamentModel
|
||||
public function getRanking()
|
||||
{
|
||||
$players = $this->getPlayers();
|
||||
$rankingsArray = array();
|
||||
foreach ($players as $player) {
|
||||
$rankingsArray[$player->getPoints()] = $player;
|
||||
}
|
||||
ksort($rankingsArray);
|
||||
|
||||
$finalArray = array();
|
||||
$i = 0;
|
||||
foreach ($rankingsArray as $ranking) {
|
||||
$finalArray[$i] = $ranking;
|
||||
$i++;
|
||||
}
|
||||
usort($players, array($this, "cmp"));
|
||||
|
||||
return $finalArray;
|
||||
return $players;
|
||||
}
|
||||
|
||||
private function cmp($a, $b)
|
||||
{
|
||||
return $b->getPoints() - $a->getPoints();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user