sort the all bots list

This commit is contained in:
Fraser Graham
2013-11-06 21:12:19 -08:00
parent 855b8518b8
commit cd9bb45ddc
2 changed files with 18 additions and 0 deletions
+17
View File
@@ -56,6 +56,23 @@ func (s RobotSorter) Less(i, j int) bool {
return s.Robots[i].Id < s.Robots[j].Id
}
// TODO - how do I not duplicate this code???
type AllRobotSorter struct {
Robots []BotHealth
}
func (s AllRobotSorter) Len() int {
return len(s.Robots)
}
func (s AllRobotSorter) Swap(i, j int) {
s.Robots[i], s.Robots[j] = s.Robots[j], s.Robots[i]
}
func (s AllRobotSorter) Less(i, j int) bool {
return s.Robots[i].RobotId < s.Robots[j].RobotId
}
type Stats struct {
Hp int `json:"-"`
Speed float32 `json:"-"`