add tracklist sorting logic

This commit is contained in:
Drew Weymouth
2023-05-23 11:10:43 -07:00
parent e434b55dda
commit 1f3559de43
7 changed files with 162 additions and 79 deletions
+22
View File
@@ -40,6 +40,28 @@ func MapSlice[T any, U any](ts []T, f func(T) U) []U {
return result
}
func IndexOf[T comparable](ts []T, t T) int {
for i, tt := range ts {
if t == tt {
return i
}
}
return -1
}
func Reversed[T any](ts []T) []T {
if ts == nil {
return nil
}
new := make([]T, len(ts))
j := len(ts) - 1
for i := range ts {
new[i] = ts[j]
j--
}
return new
}
func FindTrackByID(id string, tracks []*mediaprovider.Track) *mediaprovider.Track {
for _, tr := range tracks {
if id == tr.ID {