trueskill/src/RankSorter.php

24 lines
601 B
PHP
Raw Normal View History

2022-07-05 13:55:47 +00:00
<?php
namespace DNW\Skills;
/**
* Helper class to sort ranks in non-decreasing order.
*/
class RankSorter
{
/**
* Performs an in-place sort of the items in according to the ranks in non-decreasing order.
*
2023-08-02 14:14:10 +00:00
* @param array<mixed> $teams The items to sort according to the order specified by ranks.
2023-08-03 10:09:24 +00:00
* @param array<int> $teamRanks The ranks for each item where 1 is first place.
2023-08-08 07:51:05 +00:00
* @return array<int>
*/
2023-08-02 13:19:35 +00:00
public static function sort(array &$teams, array &$teamRanks): array
2022-07-05 13:33:34 +00:00
{
array_multisort($teamRanks, $teams);
2022-07-05 13:55:47 +00:00
return $teams;
}
2022-07-05 13:55:47 +00:00
}