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()
|
public function getRanking()
|
||||||
{
|
{
|
||||||
$players = $this->getPlayers();
|
$players = $this->getPlayers();
|
||||||
$rankingsArray = array();
|
|
||||||
foreach ($players as $player) {
|
|
||||||
$rankingsArray[$player->getPoints()] = $player;
|
|
||||||
}
|
|
||||||
ksort($rankingsArray);
|
|
||||||
|
|
||||||
$finalArray = array();
|
usort($players, array($this, "cmp"));
|
||||||
$i = 0;
|
|
||||||
foreach ($rankingsArray as $ranking) {
|
|
||||||
$finalArray[$i] = $ranking;
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return $finalArray;
|
return $players;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function cmp($a, $b)
|
||||||
|
{
|
||||||
|
return $b->getPoints() - $a->getPoints();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user