From 48725a79370ee2b94dcf6bf3455cd9ec33da123e Mon Sep 17 00:00:00 2001 From: leo Date: Mon, 28 Oct 2024 19:42:54 +0800 Subject: [PATCH] code_review: PR #612 Signed-off-by: leo --- src/Models/NumericSort.cs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/Models/NumericSort.cs b/src/Models/NumericSort.cs index 64f6540b..58e757b6 100644 --- a/src/Models/NumericSort.cs +++ b/src/Models/NumericSort.cs @@ -50,22 +50,9 @@ string sub2 = new string(tmp2, 0, loc2); int result; if (isDigit1 && isDigit2) - { - // compare numeric values - if (sub1.Length == sub2.Length) - { - // if length is the same, lexicographical comparison is good also for numbers - result = string.CompareOrdinal(sub1, sub2); - } - else - { - result = sub1.Length.CompareTo(sub2.Length); - } - } + result = loc1 == loc2 ? string.CompareOrdinal(sub1, sub2) : loc1 - loc2; else - { - result = string.Compare(sub1, sub2, System.StringComparison.Ordinal); - } + result = string.CompareOrdinal(sub1, sub2); if (result != 0) return result;