22 lines
391 B
Go
22 lines
391 B
Go
package passon
|
|
|
|
import "go_dreamfactory/pb"
|
|
|
|
type SliceHero []*pb.DBHero
|
|
|
|
// 实现sort.Interface接口的方法
|
|
// 获取数组长度
|
|
func (this SliceHero) Len() int {
|
|
return len(this)
|
|
}
|
|
|
|
// 比较元素大小
|
|
func (this SliceHero) Less(i, j int) bool {
|
|
return this[i].Lv < this[j].Lv
|
|
}
|
|
|
|
// 交换元素位置
|
|
func (this SliceHero) Swap(i, j int) {
|
|
this[i], this[j] = this[j], this[i]
|
|
}
|