summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/structs.go7
1 files changed, 6 insertions, 1 deletions
diff --git a/core/structs.go b/core/structs.go
index 6595100..e5a3ab5 100644
--- a/core/structs.go
+++ b/core/structs.go
@@ -148,15 +148,20 @@ type PageEntries struct {
Entries []*PageEntry
}
-// Implement sort.Interface
+// Implement sort.Interface for PageEntries
+
+// Len returns the length of Entries
func (e *PageEntries) Len() int {
return len(e.Entries)
}
+// Less compares the Published if Entries[i], Entries[j] and returns true if
+// Entries[i] is /after/ Entries[j] (for reverse chronological sorting)
func (e *PageEntries) Less(i, j int) bool {
return e.Entries[i].Published.After(e.Entries[j].Published)
}
+// Swap swaps Entries[i] and Entries[j]
func (e *PageEntries) Swap(i, j int) {
e.Entries[i], e.Entries[j] = e.Entries[j], e.Entries[i]
}