pünktchen 1259 Posted July 28, 2023 Share Posted July 28, 2023 How i can sort episode items so that specials are listed between regular episodes? Link to comment Share on other sites More sharing options...
pünktchen 1259 Posted August 1, 2023 Author Share Posted August 1, 2023 Nobody? @Luke Link to comment Share on other sites More sharing options...
Luke 37119 Posted August 1, 2023 Share 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? Link to comment Share on other sites More sharing options...
pünktchen 1259 Posted August 1, 2023 Author Share 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(); Link to comment Share on other sites More sharing options...
Luke 37119 Posted August 1, 2023 Share 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. Link to comment Share on other sites More sharing options...
pünktchen 1259 Posted August 1, 2023 Author Share 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. Link to comment Share on other sites More sharing options...
Solution Luke 37119 Posted August 1, 2023 Solution Share 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 Link to comment Share on other sites More sharing options...
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