summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/structs.go18
1 files changed, 18 insertions, 0 deletions
diff --git a/core/structs.go b/core/structs.go
index a97fc74..6595100 100644
--- a/core/structs.go
+++ b/core/structs.go
@@ -92,6 +92,24 @@ func GofeedConvert(f *gofeed.Feed, title string) (*Feed, error) {
return new, nil
}
+// Implement sort.Interface for Feed
+
+// Len returns the length of Items.
+func (f *Feed) Len() int {
+ return len(f.Items)
+}
+
+// Less compares Published of Items[i], Items[k] and returns true if Items[i] is
+// before Items[j].
+func (f *Feed) Less(i, j int) {
+ return f.Items[i].Published.Before(f.Items[j].Published)
+}
+
+// Swap swaps Items[i] and Items[j].
+func (f *Feed) Swap(i, j int) {
+ f.Items[i], f.Items[j] = f.Items[j], f.Items[i]
+}
+
// Lock locks both feed and page mutexes.
func (j *jsonData) Lock() {
j.feedsMu.Lock()