Relative Content

Tag Archive for javascripttypescriptalgorithmsorting

Sorting a 2D array of matchups so that each team has equal number of home and away matches

I’m trying to create a UEFA Champions League 24 ‘Swiss Model’ competition featuring 36 teams. Each team will compete against 8 unique opponents, resulting in a total of 144 matches. I have already created a list of matchups. Is there a way to sort every matchup so that each team can have an equal number (4 in this case) of home and away games? The first position in a matchup indicates the home team, while the second position indicates the away team.