From 4dae45a68ff1ff32a251a5835b2a2723ae125d1c Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 21 Mar 2020 09:55:06 +1000 Subject: Restructured source code layout, Added rice support for templates and static assets --- media/playlist.go | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 media/playlist.go (limited to 'media/playlist.go') diff --git a/media/playlist.go b/media/playlist.go new file mode 100644 index 0000000..cf8edcf --- /dev/null +++ b/media/playlist.go @@ -0,0 +1,19 @@ +package media + +// Playlist holds an array of videos capable of sorting by Timestamp. +type Playlist []*Video + +// Len returns length of array (for sorting). +func (p Playlist) Len() int { + return len(p) +} + +// Swap swaps two values in array by index (for sorting). +func (p Playlist) Swap(i, j int) { + p[i], p[j] = p[j], p[i] +} + +// Less returns true if p[i] Timestamp is after p[j] (for sorting). +func (p Playlist) Less(i, j int) bool { + return p[i].Timestamp.After(p[j].Timestamp) +} -- cgit v1.2.3