<commit_before>// Package leaderboard
package leaderboard

import (
	"errors"
	"sort"
)

type Color struct {
	R float32
	G float32
	B float32
}

type Player struct {
	Username string
	Team     struct {
		R float32
		G float32
		B float32
	}
	HomePlanet string
	Planets    uint32
}

type Team struct {
	Name    string
	Color   Color
	Players uint32
	Planets uint32
}

type Teams []*Team

type Leaderboard struct {
	places map[string]int
	board  []*Player
	teams  Teams
}

func New() *Leaderboard {
	l := new(Leaderboard)
	l.places = make(map[string]int)
	l.board = make([]*Player, 0)
	l.teams = make([]*Team, 0)
	return l
}

func (l *Leaderboard) Add(player *Player) {
	l.board = append(l.board, player)
	l.places[player.Username] = len(l.board) - 1

	for _, team := range l.teams {
		if player.Team == team.Color {
			team.Players++
			team.Planets += player.Planets
			return
		}
	}

	l.teams = append(l.teams, &Team{
		Name:    "<NAME>",
		Color:   player.Team,
		Players: 1,
		Planets: player.Planets,
	})
}

func (l *Leaderboard) FindTeam(color Color) *Team {
	for _, team := range l.teams {
		if team.Color == color {
			return team
		}
	}
	return nil
}

func (l *Leaderboard) Len() int {
	return len(l.board)
}

func (l *Leaderboard) Swap(i, j int) {
	l.board[i], l.board[j] = l.board[j], l.board[i]
}

func (l *Leaderboard) Less(i, j int) bool {
	return l.board[i].Planets > l.board[j].Planets
}

func (l *Leaderboard) Sort() {
	sort.Sort(l)
	for index, player := range l.board {
		l.places[player.Username] = index
	}
}

func (l *Leaderboard) RecountTeamsPlanets() {
	for _, team := range l.teams {
		team.Planets = 0<commit_msg>Sort teams after sorting players<commit_after>// Package leaderboard
package leaderboard

import (
	"errors"
	"sort"
)

type Color struct {
	R float32
	G float32
	B float32
}

type Player struct {
	Username string
	Team     struct {
		R float32
		G float32
		B float32
	}
	HomePlanet string
	Planets    uint32
}

type Team struct {
	Name    string
	Color   Color
	Players uint32
	Planets uint32
}

type Teams []*Team

type Leaderboard struct {
	places map[string]int
	board  []*Player
	teams  Teams
}

func New() *Leaderboard {
	l := new(Leaderboard)
	l.places = make(map[string]int)
	l.board = make([]*Player, 0)
	l.teams = make([]*Team, 0)
	return l
}

func (l *Leaderboard) Add(player *Player) {
	l.board = append(l.board, player)
	l.places[player.Username] = len(l.board) - 1

	for _, team := range l.teams {
		if player.Team == team.Color {
			team.Players++
			team.Planets += player.Planets
			return
		}
	}

	l.teams = append(l.teams, &Team{
		Name:    "Red Panda",
		Color:   player.Team,
		Players: 1,
		Planets: player.Planets,
	})
}

func (l *Leaderboard) FindTeam(color Color) *Team {
	for _, team := range l.teams {
		if team.Color == color {
			return team
		}
	}
	return nil
}

func (l *Leaderboard) Len() int {
	return len(l.board)
}

func (l *Leaderboard) Swap(i, j int) {
	l.board[i], l.board[j] = l.board[j], l.board[i]
}

func (l *Leaderboard) Less(i, j int) bool {
	return l.board[i].Planets > l.board[j].Planets
}

func (l *Leaderboard) Sort() {
	sort.Sort(l)
	for index, player := range l.board {
		l.places[player.Username] = index
	}
	l.teams.Sort()
}

func (l *Leaderboard) RecountTeamsPlanets() {
	for _, team := range l.teams {
		team.Planets = 0
{'fraction_non_alphanumeric': 0.13828502415458938, 'fraction_numerical': 0.013888888888888888, 'mean_word_length': 3.3025974025974025, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2943128', 'n_tokens_mistral': 1407, 'n_tokens_neox': 1316, 'n_words': 347}