File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,10 @@ public static int Compare(string s1, string s2)
21
21
int loc2 = 0 ;
22
22
23
23
bool isDigit1 = char . IsDigit ( c1 ) ;
24
+ bool isDigit2 = char . IsDigit ( c2 ) ;
25
+ if ( isDigit1 != isDigit2 )
26
+ return c1 . CompareTo ( c2 ) ;
27
+
24
28
do
25
29
{
26
30
tmp1 [ loc1 ] = c1 ;
@@ -33,7 +37,6 @@ public static int Compare(string s1, string s2)
33
37
break ;
34
38
} while ( char . IsDigit ( c1 ) == isDigit1 ) ;
35
39
36
- bool isDigit2 = char . IsDigit ( c2 ) ;
37
40
do
38
41
{
39
42
tmp2 [ loc2 ] = c2 ;
@@ -49,7 +52,7 @@ public static int Compare(string s1, string s2)
49
52
string sub1 = new string ( tmp1 , 0 , loc1 ) ;
50
53
string sub2 = new string ( tmp2 , 0 , loc2 ) ;
51
54
int result ;
52
- if ( isDigit1 && isDigit2 )
55
+ if ( isDigit1 )
53
56
result = loc1 == loc2 ? string . CompareOrdinal ( sub1 , sub2 ) : loc1 - loc2 ;
54
57
else
55
58
result = string . CompareOrdinal ( sub1 , sub2 ) ;
You can’t perform that action at this time.
0 commit comments