pünktchen 1350 Posted July 28, 2023 Posted July 28, 2023 How i can sort episode items so that specials are listed between regular episodes?
Luke 40077 Posted August 1, 2023 Posted August 1, 2023 Hi, where are you calling from, a plugin, or the api? Are you pulling down episodes from a single series or all episodes from the library?
pünktchen 1350 Posted August 1, 2023 Author Posted August 1, 2023 1 hour ago, Luke said: Hi, where are you calling from, a plugin, or the api? Plugin. 1 hour ago, Luke said: Are you pulling down episodes from a single series or all episodes from the library? Multiple series but not necessary all. var sortedEpisodeList = unsortedEpisodeList.OrderBy(e => e.DisplayParent.DisplayParent.Name).ThenBy(e => e.ParentIndexNumber).ThenBy(e => e.IndexNumber).ToList();
Luke 40077 Posted August 1, 2023 Posted August 1, 2023 OK, in your query to get the episodes from the series, just don't explicitly specify a sort order in your query and then you'll get the correct order.
pünktchen 1350 Posted August 1, 2023 Author Posted August 1, 2023 There's no way to do it afterwards? I'm doing several other things with the output of the initial query which in turn results in an unsorted list of episodes.
Solution Luke 40077 Posted August 1, 2023 Solution Posted August 1, 2023 We do this with a database query, not managed c#. So yes you can recreate it, but there isn't a ready made method you can call. Try this for starters, off the top of my head: new List<Episode>() .OrderBy(i => i.SortParentIndexNumber ?? i.ParentIndexNumber) .ThenBy(i => i.SortIndexNumber ?? i.IndexNumber) .ThenBy(i => i.PremiereDate) .ThenBy(i => i.SortName) That should be a close enough starting point. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now