improve episode sorting

This commit is contained in:
Luke Pulverenti 2013-12-08 16:31:14 -05:00
parent 803d60d9cf
commit 91b5a8101f
3 changed files with 12 additions and 4 deletions

View File

@ -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);
}

View File

@ -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
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
return AlphanumComparator.CompareValues(x.Name, y.Name);
}
/// <summary>

View File

@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
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)