typeInterfaceinterface {// Len is the number of elements in the collection.Len() int// Less reports whether the element with// index i should sort before the element with index j.Less(i, j int) bool// Swap swaps the elements with indexes i and j.Swap(i, j int)}-------------------------------------------------------------------------typePersonstruct { Name string Age int}// ByAge implements sort.Interface based on the Age field.typeByAge []Personfunc (a ByAge) Len() int { returnlen(a) }func (a ByAge) Less(i, j int) bool { return a[i].Age < a[j].Age }func (a ByAge) Swap(i, j int) { a[i], a[j] = a[j], a[i] }funcmain() { family := []Person{ {"Alice", 23}, {"Eve", 2}, {"Bob", 25}, } sort.Sort(ByAge(family)) fmt.Println(family) // [{Eve 2} {Alice 23} {Bob 25}]}