Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 48725a7

Browse files
code_review: PR #612
Signed-off-by: leo <longshuang@msn.cn>
1 parent a363f67 commit 48725a7

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

‎src/Models/NumericSort.cs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,22 +50,9 @@ public static int Compare(string s1, string s2)
5050
string sub2 = new string(tmp2, 0, loc2);
5151
int result;
5252
if (isDigit1 && isDigit2)
53-
{
54-
// compare numeric values
55-
if (sub1.Length == sub2.Length)
56-
{
57-
// if length is the same, lexicographical comparison is good also for numbers
58-
result = string.CompareOrdinal(sub1, sub2);
59-
}
60-
else
61-
{
62-
result = sub1.Length.CompareTo(sub2.Length);
63-
}
64-
}
53+
result = loc1 == loc2 ? string.CompareOrdinal(sub1, sub2) : loc1 - loc2;
6554
else
66-
{
67-
result = string.Compare(sub1, sub2, System.StringComparison.Ordinal);
68-
}
55+
result = string.CompareOrdinal(sub1, sub2);
6956

7057
if (result != 0)
7158
return result;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /