blog/models/contacts/sorting.go

11 lines
258 B
Go
Raw Permalink Normal View History

2018-05-01 00:50:39 +00:00
package contacts
// ByName sorts contacts by name.
type ByName []*Contact
func (a ByName) Len() int { return len(a) }
func (a ByName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByName) Less(i, j int) bool {
return a[i].Name() < a[j].Name()
}