aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs
diff options
context:
space:
mode:
authorLuke <luke.pulverenti@gmail.com>2016-03-25 13:52:15 -0400
committerLuke <luke.pulverenti@gmail.com>2016-03-25 13:52:15 -0400
commit72fe76ab1008f0bd38157cc37cde45797b5f6417 (patch)
tree875b6bee7d0a634d7ef019cfb7c434823b223001 /MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs
parent736e63241011cb9ae798bf4091cd37e097045c21 (diff)
parentf6c18200bacae6e768225a8c073418a170d349bd (diff)
Merge pull request #1593 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs')
-rw-r--r--MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs25
1 files changed, 3 insertions, 22 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++;