Sort extended standings

This commit is contained in:
Peter 2025-02-24 18:03:59 -06:00
parent b25118ccb5
commit 276be58777

View File

@ -23,7 +23,7 @@
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr v-for="(team, index) in division.teamStandings" :key="index"> <tr v-for="(team, index) in getSortedStandings(division.teamStandings)" :key="index">
<td> <td>
<RouterLink <RouterLink
:to="{ name: 'team', params: { seasonNumber: seasonNumber(), teamAbbreviation: team.teamAbbreviation } }"> :to="{ name: 'team', params: { seasonNumber: seasonNumber(), teamAbbreviation: team.teamAbbreviation } }">
@ -96,6 +96,14 @@ export default {
}, },
seasonNumber(): number { seasonNumber(): number {
return CURRENT_SEASON return CURRENT_SEASON
},
getSortedStandings(teamStandings: TeamStanding[]): TeamStanding[] {
if (!teamStandings) return []
return teamStandings.slice()
.sort((t1, t2) =>
(t2.wins - t2.losses) !== (t1.wins - t1.losses)
? (t2.wins - t2.losses) - (t1.wins - t1.losses)
: (t2.wins + t2.losses) - (t1.wins + t1.losses))
} }
} }
} }