You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've used this piece of code to sort the teams (I didn't test the goal balance and most goals scored criterias but I think it's working well) :
const compareCallBack = (team1, team2) => {
if (team1.group_points < team2.group_points)
return 1
if (team1.group_points > team2.group_points)
return -1
// if the teams have the same points number, use the goal balance (goals_for - goals_against) as criteria
if (team1.group_points === team2.group_points) {
const saldoGTeam1 = team1.goals_for - team1.goals_against
const saldoGTeam2 = team2.goals_for - team2.goals_against
if (saldoGTeam1 < saldoGTeam2)
return 1
if (saldoGTeam1 > saldoGTeam2)
return -1
// if also draw in goal balance use most goals scored (goals_for) as criteria
if (saldoGTeam1 === saldoGTeam2){
if(team1.goals_for < team2.goals_for)
return 1
if(team1.goals_for > team2.goals_for)
return -1
}
}
return 0
}
I've used this piece of code to sort the teams (I didn't test the goal balance and most goals scored criterias but I think it's working well) :
The text was updated successfully, but these errors were encountered: