Skip to content

Commit 100929a

Browse files
Update src/Files.App/Helpers/NaturalStringComparer.cs
Co-authored-by: Lamparter <[email protected]> Signed-off-by: Neth Botheju <[email protected]>
1 parent 4846b13 commit 100929a

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/Files.App/Helpers/NaturalStringComparer.cs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,26 +63,26 @@ public int Compare(ReadOnlyMemory<char> x, ReadOnlyMemory<char> y)
6363

6464
public static int Compare(ReadOnlySpan<char> x, ReadOnlySpan<char> y, StringComparison stringComparison)
6565
{
66-
// Handle file extensions specially
67-
int xExtPos = GetExtensionPosition(x);
68-
int yExtPos = GetExtensionPosition(y);
69-
70-
// If both have extensions, compare the names first
71-
if (xExtPos >= 0 && yExtPos >= 0)
72-
{
73-
var xName = x.Slice(0, xExtPos);
74-
var yName = y.Slice(0, yExtPos);
75-
76-
int nameCompare = CompareWithoutExtension(xName, yName, stringComparison);
77-
if (nameCompare != 0)
78-
return nameCompare;
79-
80-
// If names match, compare extensions
81-
return x.Slice(xExtPos).CompareTo(y.Slice(yExtPos), stringComparison);
82-
}
83-
84-
// Original comparison logic for non-extension cases
85-
return CompareWithoutExtension(x, y, stringComparison);
66+
// Handle file extensions specially
67+
int xExtPos = GetExtensionPosition(x);
68+
int yExtPos = GetExtensionPosition(y);
69+
70+
// If both have extensions, compare the names first
71+
if (xExtPos >= 0 && yExtPos >= 0)
72+
{
73+
var xName = x.Slice(0, xExtPos);
74+
var yName = y.Slice(0, yExtPos);
75+
76+
int nameCompare = CompareWithoutExtension(xName, yName, stringComparison);
77+
if (nameCompare != 0)
78+
return nameCompare;
79+
80+
// If names match, compare extensions
81+
return x.Slice(xExtPos).CompareTo(y.Slice(yExtPos), stringComparison);
82+
}
83+
84+
// Original comparison logic for non-extension cases
85+
return CompareWithoutExtension(x, y, stringComparison);
8686
}
8787

8888
private static int CompareWithoutExtension(ReadOnlySpan<char> x, ReadOnlySpan<char> y, StringComparison stringComparison)

0 commit comments

Comments
 (0)