summaryrefslogtreecommitdiff
path: root/media
diff options
context:
space:
mode:
authorJames Mills <prologic@shortcircuit.net.au>2020-03-25 16:35:06 +1000
committerJames Mills <prologic@shortcircuit.net.au>2020-03-25 16:35:06 +1000
commitf0ac95bb7cc8ed539f5e0447694a3d6974dd0336 (patch)
tree4c9fe7157ac168834858f77d38c69fc64234e5a4 /media
parentdd97030bd1182f8e0da88b46505973f19e9f19ae (diff)
Fix sort order of trendingv1.1.2
Diffstat (limited to 'media')
-rw-r--r--media/playlist.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/media/playlist.go b/media/playlist.go
index ccfcc79..8686f77 100644
--- a/media/playlist.go
+++ b/media/playlist.go
@@ -7,7 +7,7 @@ import (
type Playlist []*Video
// By is the type of a "less" function that defines the ordering of its Playlist arguments.
-type By func(p1, p2 *Video) bool
+type By func(v1, v2 *Video) bool
// Sort is a method on the function type, By, that sorts the argument slice according to the function.
func (by By) Sort(pl Playlist) {
@@ -21,7 +21,7 @@ func (by By) Sort(pl Playlist) {
// playlistSorter joins a By function and a slice of Playlist to be sorted.
type playlistSorter struct {
pl Playlist
- by func(p1, p2 *Video) bool // Closure used in the Less method.
+ by func(v1, v2 *Video) bool // Closure used in the Less method.
}
// Len is part of sort.Interface.
@@ -39,10 +39,12 @@ func (s *playlistSorter) Less(i, j int) bool {
return s.by(s.pl[i], s.pl[j])
}
+// SortByTimestamp sorts the playlist by Timestamp
func SortByTimestamp(v1, v2 *Video) bool {
return v1.Timestamp.After(v2.Timestamp)
}
+// SortByViews sorts the playlist by Views
func SortByViews(v1, v2 *Video) bool {
- return v1.Views < v2.Views
+ return v1.Views > v2.Views
}