We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 6c390d2 commit a363f67Copy full SHA for a363f67
src/Models/NumericSort.cs
@@ -51,9 +51,16 @@ public static int Compare(string s1, string s2)
51
int result;
52
if (isDigit1 && isDigit2)
53
{
54
- int num1 = int.Parse(sub1);
55
- int num2 = int.Parse(sub2);
56
- result = num1 - num2;
+ // compare numeric values
+ if (sub1.Length == sub2.Length)
+ {
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
}
65
else
66
0 commit comments