aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Sorting
diff options
context:
space:
mode:
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sorting')
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs25
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/NameComparer.cs7
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs2
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/SortNameComparer.cs7
4 files changed, 6 insertions, 35 deletions
diff --git a/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs b/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs
index b76bf0a9c..232bdb3b5 100644
--- a/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs
+++ b/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs
@@ -1,30 +1,11 @@
using System.Collections.Generic;
using System.Text;
+using MediaBrowser.Controller.Sorting;
namespace MediaBrowser.Server.Implementations.Sorting
{
public class AlphanumComparator : IComparer<string>
{
- private enum ChunkType { Alphanumeric, Numeric };
-
- private static bool InChunk(char ch, char otherCh)
- {
- var type = ChunkType.Alphanumeric;
-
- if (char.IsDigit(otherCh))
- {
- type = ChunkType.Numeric;
- }
-
- if ((type == ChunkType.Alphanumeric && char.IsDigit(ch))
- || (type == ChunkType.Numeric && !char.IsDigit(ch)))
- {
- return false;
- }
-
- return true;
- }
-
public static int CompareValues(string s1, string s2)
{
if (s1 == null || s2 == null)
@@ -51,7 +32,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
StringBuilder thisChunk = new StringBuilder();
StringBuilder thatChunk = new StringBuilder();
- while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || InChunk(thisCh, thisChunk[0])))
+ while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || SortHelper.InChunk(thisCh, thisChunk[0])))
{
thisChunk.Append(thisCh);
thisMarker++;
@@ -62,7 +43,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
}
}
- while ((thatMarker < s2.Length) && (thatChunk.Length == 0 || InChunk(thatCh, thatChunk[0])))
+ while ((thatMarker < s2.Length) && (thatChunk.Length == 0 || SortHelper.InChunk(thatCh, thatChunk[0])))
{
thatChunk.Append(thatCh);
thatMarker++;
diff --git a/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs
index 18fddb903..49f86c485 100644
--- a/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs
+++ b/MediaBrowser.Server.Implementations/Sorting/NameComparer.cs
@@ -18,12 +18,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
- if (!x.EnableAlphaNumericSorting || !y.EnableAlphaNumericSorting)
- {
- return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
- }
-
- return AlphanumComparator.CompareValues(x.Name, y.Name);
+ return string.Compare(x.Name, y.Name, StringComparison.CurrentCultureIgnoreCase);
}
/// <summary>
diff --git a/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs
index 09612a49c..4efc3218b 100644
--- a/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs
+++ b/MediaBrowser.Server.Implementations/Sorting/SeriesSortNameComparer.cs
@@ -16,7 +16,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
- return AlphanumComparator.CompareValues(GetValue(x), GetValue(y));
+ return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase);
}
private string GetValue(BaseItem item)
diff --git a/MediaBrowser.Server.Implementations/Sorting/SortNameComparer.cs b/MediaBrowser.Server.Implementations/Sorting/SortNameComparer.cs
index 389b21ba7..873753a2b 100644
--- a/MediaBrowser.Server.Implementations/Sorting/SortNameComparer.cs
+++ b/MediaBrowser.Server.Implementations/Sorting/SortNameComparer.cs
@@ -18,12 +18,7 @@ namespace MediaBrowser.Server.Implementations.Sorting
/// <returns>System.Int32.</returns>
public int Compare(BaseItem x, BaseItem y)
{
- if (!x.EnableAlphaNumericSorting || !y.EnableAlphaNumericSorting)
- {
- return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
- }
-
- return AlphanumComparator.CompareValues(x.SortName, y.SortName);
+ return string.Compare(x.SortName, y.SortName, StringComparison.CurrentCultureIgnoreCase);
}
/// <summary>