code_review: PR #612

Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
leo 2024-10-28 19:42:54 +08:00
parent a363f67f31
commit 48725a7937
No known key found for this signature in database

View file

@ -50,22 +50,9 @@
string sub2 = new string(tmp2, 0, loc2); string sub2 = new string(tmp2, 0, loc2);
int result; int result;
if (isDigit1 && isDigit2) if (isDigit1 && isDigit2)
{ result = loc1 == loc2 ? string.CompareOrdinal(sub1, sub2) : loc1 - loc2;
// compare numeric values else
if (sub1.Length == sub2.Length)
{
// if length is the same, lexicographical comparison is good also for numbers
result = string.CompareOrdinal(sub1, sub2); result = string.CompareOrdinal(sub1, sub2);
}
else
{
result = sub1.Length.CompareTo(sub2.Length);
}
}
else
{
result = string.Compare(sub1, sub2, System.StringComparison.Ordinal);
}
if (result != 0) if (result != 0)
return result; return result;