Sort teams more explicitly and in the right order

This commit is contained in:
Daniel Schädler 2019-06-17 12:50:26 +02:00
parent 15e2bd830f
commit 54ab1570b1
1 changed files with 7 additions and 4 deletions

View File

@ -61,10 +61,13 @@ class GroupStageService
# @param group Group the group to get the teams from
# @return [Array] of teams
def teams_sorted_by_group_scores(group)
group.teams.sort_by do |t|
[group.group_scores.find_by(team: t).group_points,
group.group_scores.find_by(team: t).difference_in_points,
group.group_scores.find_by(team: t).scored_points]
group.teams.sort do |a, b|
[group.group_scores.find_by(team: b).group_points,
group.group_scores.find_by(team: b).difference_in_points,
group.group_scores.find_by(team: b).scored_points] <=>
[group.group_scores.find_by(team: a).group_points,
group.group_scores.find_by(team: a).difference_in_points,
group.group_scores.find_by(team: a).scored_points]
end
end