What is the shortest way to simply sort an array of structs by (arbitrary) field names?

I just had a problem where I had an array of structs, e.g. package main import “log” type Planet struct { Name string `json:”name”` Aphelion float64 `json:”aphelion”` // in million km Perihelion float64 `json:”perihelion”` // in million km Axis int64 `json:”Axis”` // in km Radius float64 `json:”radius”` } func main() { var mars = new(Planet) … Read more