What does the implementation of `byName` look like? I'm not sure I understand what its return type would be.
type byName []Machine
func (b byName) Len() int { return len(b) }
func (b byName) Swap(i, j int) { b[j], b[i] = b[i], [b[j] }
func (b byName) Less(i, j int) { return b[i].Name < b[j].Name }
sort.Sort takes an interface type that has the methods Len, Swap, and Less, as defined in the signatures above, and uses them in a sorting algorithm which sorts the values in-place.If so, that seems like quite a lot of boilerplate, no?
In a million lines of code, this costs us approximately 114 extra lines of code beyond the minimum necessary for any language where you need to specify a sort order (assuming you need at least one line of code per type/sort algo to tell the computer how to sort your random list of objects).
So, it depends on what you mean by a "lot".