improve episode sorting

pull/702/head
Luke Pulverenti 11 years ago
parent 803d60d9cf
commit 91b5a8101f

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

@ -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>

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

Loading…
Cancel
Save