mirror of
https://github.com/sourcegit-scm/sourcegit
synced 2025-06-17 16:34:59 +00:00
refactor: now all filesystem related trees/lists are sorted in case-insensitive mode
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
parent
c3c7d32167
commit
5494093261
6 changed files with 22 additions and 19 deletions
|
@ -1,4 +1,7 @@
|
|||
namespace SourceGit.Models
|
||||
using System;
|
||||
using System.Globalization;
|
||||
|
||||
namespace SourceGit.Models
|
||||
{
|
||||
public static class NumericSort
|
||||
{
|
||||
|
@ -23,7 +26,7 @@
|
|||
bool isDigit1 = char.IsDigit(c1);
|
||||
bool isDigit2 = char.IsDigit(c2);
|
||||
if (isDigit1 != isDigit2)
|
||||
return c1.CompareTo(c2);
|
||||
return char.ToUpper(c1, CultureInfo.CurrentCulture).CompareTo(char.ToUpper(c2, CultureInfo.CurrentCulture));
|
||||
|
||||
do
|
||||
{
|
||||
|
@ -55,7 +58,7 @@
|
|||
if (isDigit1)
|
||||
result = loc1 == loc2 ? string.CompareOrdinal(sub1, sub2) : loc1 - loc2;
|
||||
else
|
||||
result = string.CompareOrdinal(sub1, sub2);
|
||||
result = string.Compare(sub1, sub2, StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
if (result != 0)
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue