sort the all bots list
This commit is contained in:
@@ -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:"-"`
|
||||
|
||||
Reference in New Issue
Block a user