diff --git a/files/models.py b/files/models.py index 1d539cc..3f653d4 100644 --- a/files/models.py +++ b/files/models.py @@ -775,7 +775,11 @@ class Media(models.Model): """ ret = [] - for subtitle in self.subtitles.all(): + + # Retrieve all subtitles and sort by the first letter of their associated language's title + sorted_subtitles = sorted(self.subtitles.all(), key=lambda s: s.language.title[0]) + + for subtitle in sorted_subtitles: ret.append( { "src": helpers.url_from_path(subtitle.subtitle_file.path),