From a363f67f3189501180197af1971234a22464aa96 Mon Sep 17 00:00:00 2001 From: ybeapps Date: Mon, 28 Oct 2024 13:24:43 +0200 Subject: [PATCH] bug: fix int out of bounds for branch names with long numbers (#612) --- src/Models/NumericSort.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Models/NumericSort.cs b/src/Models/NumericSort.cs index bdff95e6..64f6540b 100644 --- a/src/Models/NumericSort.cs +++ b/src/Models/NumericSort.cs @@ -51,9 +51,16 @@ int result; if (isDigit1 && isDigit2) { - int num1 = int.Parse(sub1); - int num2 = int.Parse(sub2); - result = num1 - num2; + // 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); + } } else {