Optionally accept a Less func to implement sort.Interface
Closed this issue · 1 comments
phelmkamp commented
Something like:
type personsLesser struct {
Persons
less func(i, j Person) bool
}
func (pl personsLesser) Less(i, j int) bool {
return pl.less(pl.Ps[i], pl.Ps[j])
}
// Sort is a convenience method.
func (p Persons) Sort(less func(i, j Person) bool) {
sort.Sort(personsLesser{
Persons: p,
less: less,
})
}
phelmkamp commented
Done