diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-08 21:24:23 -0500 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2013-12-08 21:24:23 -0500 |
| commit | d7c25fa53f636d9882b6fd77bc877fc71ddd8902 (patch) | |
| tree | 72961f7bb1ca6625a76d06a9fe4c59060a6e350e /MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs | |
| parent | 3c53aca46b7d1324d02a44ec2d7285986b7a85ad (diff) | |
fixed issue with natural sort
Diffstat (limited to 'MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs')
| -rw-r--r-- | MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs b/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs index 2ced9a566..3fbb01f77 100644 --- a/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs +++ b/MediaBrowser.Server.Implementations/Sorting/AlphanumComparator.cs @@ -33,8 +33,8 @@ namespace MediaBrowser.Server.Implementations.Sorting return 0; } - var thisMarker = 0; - var thatMarker = 0; + int thisMarker = 0, thisNumericChunk = 0; + int thatMarker = 0, thatNumericChunk = 0; while ((thisMarker < s1.Length) || (thatMarker < s2.Length)) { @@ -42,15 +42,15 @@ namespace MediaBrowser.Server.Implementations.Sorting { return -1; } - if (thatMarker >= s2.Length) + else if (thatMarker >= s2.Length) { return 1; } - var thisCh = s1[thisMarker]; - var thatCh = s2[thatMarker]; + char thisCh = s1[thisMarker]; + char thatCh = s2[thatMarker]; - var thisChunk = new StringBuilder(); - var thatChunk = new StringBuilder(); + StringBuilder thisChunk = new StringBuilder(); + StringBuilder thatChunk = new StringBuilder(); while ((thisMarker < s1.Length) && (thisChunk.Length == 0 || InChunk(thisCh, thisChunk[0]))) { @@ -78,8 +78,8 @@ namespace MediaBrowser.Server.Implementations.Sorting // If both chunks contain numeric characters, sort them numerically if (char.IsDigit(thisChunk[0]) && char.IsDigit(thatChunk[0])) { - var thisNumericChunk = Convert.ToInt32(thisChunk.ToString()); - var thatNumericChunk = Convert.ToInt32(thatChunk.ToString()); + thisNumericChunk = Convert.ToInt32(thisChunk.ToString()); + thatNumericChunk = Convert.ToInt32(thatChunk.ToString()); if (thisNumericChunk < thatNumericChunk) { @@ -93,7 +93,7 @@ namespace MediaBrowser.Server.Implementations.Sorting } else { - return string.Compare(thisChunk.ToString(), thatChunk.ToString(), StringComparison.CurrentCultureIgnoreCase); + result = thisChunk.ToString().CompareTo(thatChunk.ToString()); } if (result != 0) |
