aboutsummaryrefslogtreecommitdiff
path: root/page/pagelist.go
blob: a5cf8449c7259e143fff159f75f4a973dcbc46df (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package page

import (
	"sort"
)

// PageList is a slice of pages, providing a couple of methods to sort
// by the date, or date reversed
type PageList []*Page

func (p PageList) SortDate() PageList {
	sort.Slice(p, func(i, j int) bool {
		return p[i].Time().After(p[j].Time())
	})
	return p
}

func (p PageList) SortDateReverse() PageList {
	sort.Slice(p, func(i, j int) bool {
		return p[i].Time().Before(p[j].Time())
	})
	return p
}