From bd19b3408802ff1b3799a5df7b9caf9526b627e2 Mon Sep 17 00:00:00 2001 From: bytedream Date: Wed, 23 Feb 2022 22:32:20 +0100 Subject: [PATCH] Added sort function for subtitles by their locale --- utils/sort.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/sort.go b/utils/sort.go index 1f9092a..16ce41a 100644 --- a/utils/sort.go +++ b/utils/sort.go @@ -100,3 +100,15 @@ func (fbr FormatsByResolution) Less(i, j int) bool { return iResX+iResY < jResX+jResY } + +type SubtitlesByLocale []*crunchyroll.Subtitle + +func (sbl SubtitlesByLocale) Len() int { + return len(sbl) +} +func (sbl SubtitlesByLocale) Swap(i, j int) { + sbl[i], sbl[j] = sbl[j], sbl[i] +} +func (sbl SubtitlesByLocale) Less(i, j int) bool { + return sbl[i].Locale < sbl[j].Locale +}