blog/models/events/sorting.go

11 lines
297 B
Go
Raw Normal View History

package events
// ByDate sorts events by their start time.
type ByDate []*Event
func (a ByDate) Len() int { return len(a) }
func (a ByDate) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByDate) Less(i, j int) bool {
2018-05-01 00:50:39 +00:00
return a[i].StartTime.Before(a[j].StartTime) || a[i].ID < a[j].ID
}