Jump to content

C# plugin: How to sort episode items with specials?


Go to solution Solved by Luke,

Recommended Posts

pünktchen
Posted

How i can sort episode items so that specials are listed between regular episodes?

Posted

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
Posted
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();

 

Posted

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
Posted

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
Posted

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.

  • Thanks 1

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...