Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 11 additions & 47 deletions src/NaturalSort.Extension/NaturalSortComparer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -191,53 +191,17 @@ public int Compare(string str1, string str2)

private static byte GetTokenFromChar(char c)
{
if (c >= 'a')
return c switch
{
if (c <= 'z')
{
return TokenLetters;
}
else if (c < 128)
{
return TokenOther;
}
else if (char.IsLetter(c))
{
return TokenLetters;
}
else if (char.IsDigit(c))
{
return TokenDigits;
}
else
{
return TokenOther;
}
}
else
{
if (c >= 'A')
{
if (c <= 'Z')
{
return TokenLetters;
}
else
{
return TokenOther;
}
}
else
{
if (c is >= '0' and <= '9')
{
return TokenDigits;
}
else
{
return TokenOther;
}
}
}
>= 'a' and <= 'z' => TokenLetters,
>= 'a' when c < 128 => TokenOther,
>= 'a' when char.IsLetter(c) => TokenLetters,
>= 'a' when char.IsDigit(c) => TokenDigits,
>= 'a' => TokenOther,
>= 'A' and <= 'Z' => TokenLetters,
>= 'A' => TokenOther,
>= '0' and <= '9' => TokenDigits,
_ => TokenOther,
};
}
}