Skip to content

Commit f59851f

Browse files
committed
refactor: case-insensitive sorting
- `ToUpper` is not necessary to compare digit char with non-digit char - use numeric sorting for commit decorators with same type Signed-off-by: leo <[email protected]>
1 parent a128b67 commit f59851f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Models/Commit.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ public void ParseDecorators(string data)
113113
if (l.Type != r.Type)
114114
return (int)l.Type - (int)r.Type;
115115
else
116-
return string.Compare(l.Name, r.Name, StringComparison.Ordinal);
116+
return NumericSort.Compare(l.Name, r.Name);
117117
});
118118
}
119119
}

src/Models/NumericSort.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public static int Compare(string s1, string s2)
2626
bool isDigit1 = char.IsDigit(c1);
2727
bool isDigit2 = char.IsDigit(c2);
2828
if (isDigit1 != isDigit2)
29-
return char.ToUpper(c1, CultureInfo.CurrentCulture).CompareTo(char.ToUpper(c2, CultureInfo.CurrentCulture));
29+
return c1.CompareTo(c2);
3030

3131
do
3232
{

0 commit comments

Comments
 (0)