Ordena una variedad de estructuras en Golang
slice.Sort(planets[:], func(i, j int) bool {
return planets[i].Axis < planets[j].Axis
})
Cheerful Crayfish
slice.Sort(planets[:], func(i, j int) bool {
return planets[i].Axis < planets[j].Axis
})
type kv struct {
k string
v int
}
ss := []kv{}
for k, v := range results {
ss = append(ss, kv{k, v})
}
sort.Slice(ss, func(i, j int) bool {
return ss[i].v > ss[j].v
})
for _, kv := range ss {
fmt.Printf("%s, %d\n", kv.k, kv.v)
}