1
0
mirror of https://github.com/danog/gojekyll.git synced 2024-12-02 15:57:49 +01:00
gojekyll/collection/sort.go

21 lines
440 B
Go
Raw Normal View History

2017-07-04 15:09:36 +02:00
package collection
2017-07-03 15:48:41 +02:00
2017-09-03 18:18:17 +02:00
type pagesByDate struct{ pages []Page }
2017-07-03 15:48:41 +02:00
// Len is part of sort.Interface.
func (p pagesByDate) Len() int {
return len(p.pages)
}
// Less is part of sort.Interface.
func (p pagesByDate) Less(i, j int) bool {
a, b := p.pages[i].PostDate(), p.pages[j].PostDate()
2017-07-03 19:03:45 +02:00
return a.After(b)
2017-07-03 15:48:41 +02:00
}
// Swap is part of sort.Interface.
func (p pagesByDate) Swap(i, j int) {
pages := p.pages
pages[i], pages[j] = pages[j], pages[i]
}