// TeamStandings returns the current position of Teams in the Championship.
TeamStandings returns the current position of Teams in the Championship.
// TeamStandings returns the current position of Teams in the Championship .
func (c *ChampionshipClass) TeamStandings(events []*ChampionshipEvent) []*TeamStanding {
	teams := make(map[string]float64)
	for _, driver := range c.Standings(events) {
		if _, ok := teams[driver.Entrant.Team]; !ok {
			teams[driver.Entrant.Team] = driver.Points
		} else {
			teams[driver.Entrant.Team] += driver.Points
		}
	}
	var out []*TeamStanding
	for name, pts := range teams {
		out = append(out, &TeamStanding{
			Team:   name,
			Points: pts,
		})
	}
	sort.Slice(out, func(i, j int) bool {
		return out[i].Team < out[j].Team
	})
	sort.Slice(out, func(i, j int) bool {
		return out[i].Points > out[j].Points
	})
	return out
}
func ( c * ChampionshipClass ) TeamStandings ( events [ ] * ChampionshipEvent ) [ ] * TeamStanding { teams := make ( map [ string ] float64 ) for _ , driver := range c . Standings ( events ) { if _ , ok := teams [ driver . Entrant . Team ] ; ! ok { teams [ driver . Entrant . Team ] = driver . Points } else { teams [ driver . Entrant . Team ] += driver . Points } } var out [ ] * TeamStanding for name , pts := range teams { out = append ( out , & TeamStanding { Team : name , Points : pts , } ) } sort . Slice ( out , func ( i , j int ) bool { return out [ i ] . Team < out [ j ] . Team } ) sort . Slice ( out , func ( i , j int ) bool { return out [ i ] . Points > out [ j ] . Points } ) return out }
TeamStandings returns the current position of Teams in the Championship.
TeamStandings returns the current position of Teams in the Championship .