diff --git a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs index 76971342a0..d6b78bd84b 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AiredEpisodeOrderComparer.cs @@ -62,7 +62,7 @@ namespace MediaBrowser.Server.Implementations.Sorting return CompareEpisodes(x, y); } - if (!isXSpecial && isYSpecial) + if (!isXSpecial) { return CompareEpisodeToSpecial(x, y); } @@ -87,8 +87,17 @@ namespace MediaBrowser.Server.Implementations.Sorting // Add 1 to to non-specials to account for AirsBeforeEpisodeNumber var xEpisode = x.IndexNumber ?? -1; xEpisode++; + var yEpisode = y.AirsBeforeEpisodeNumber ?? 10000; + // Sometimes they'll both have a value. + // For example AirsAfterSeasonNumber=1, AirsBeforeSeasonNumber=2, AirsBeforeEpisodeNumber=1 + // The episode should be displayed at the end of season 1 + if (y.AirsAfterSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.HasValue && y.AirsBeforeSeasonNumber.Value > y.AirsAfterSeasonNumber.Value) + { + yEpisode = 10000; + } + return xEpisode.CompareTo(yEpisode); } diff --git a/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs index 49f86c485a..83b1b2d16f 100644 --- a/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Querying; -using System; namespace MediaBrowser.Server.Implementations.Sorting { @@ -18,7 +17,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// System.Int32. public int Compare(BaseItem x, BaseItem y) { - return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase); + return AlphanumComparator.CompareValues(x.Name, y.Name); } /// diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs index 4efc3218b2..09612a49c9 100644 --- a/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs +++ b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Sorting /// System.Int32. public int Compare(BaseItem x, BaseItem y) { - return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase); + return AlphanumComparator.CompareValues(GetValue(x), GetValue(y)); } private string GetValue(BaseItem item)