2016-05-24 14:10:39 +02:00
|
|
|
<?php namespace Moserware\Skills;
|
2010-08-28 22:05:41 -04:00
|
|
|
|
2010-10-08 21:44:36 -04:00
|
|
|
/**
|
|
|
|
* Helper class to sort ranks in non-decreasing order.
|
|
|
|
*/
|
2010-08-28 22:05:41 -04:00
|
|
|
class RankSorter
|
|
|
|
{
|
2010-10-08 21:44:36 -04:00
|
|
|
/**
|
|
|
|
* Performs an in-place sort of the items in according to the ranks in non-decreasing order.
|
2016-05-24 14:10:39 +02:00
|
|
|
*
|
|
|
|
* @param array $teams The items to sort according to the order specified by ranks.
|
|
|
|
* @param array $teamRanks The ranks for each item where 1 is first place.
|
|
|
|
* @return array
|
2010-10-08 21:44:36 -04:00
|
|
|
*/
|
2010-08-28 22:05:41 -04:00
|
|
|
public static function sort(array &$teams, array &$teamRanks)
|
|
|
|
{
|
|
|
|
array_multisort($teamRanks, $teams);
|
|
|
|
return $teams;
|
|
|
|
}
|
2016-05-24 14:10:39 +02:00
|
|
|
}
|