Skip to content

Commit 627adbd

Browse files
committed
improve string handling in SortDescription.Compare
1 parent a95487a commit 627adbd

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/ItemsSource/SortDescription.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ public SortDescription(string? propertyName,
5959
/// <returns>An integer that indicates the relative order of the objects being compared.</returns>
6060
public int Compare(object? x, object? y)
6161
{
62-
return (Comparer ?? Comparer<object>.Default).Compare(x, y);
62+
if (Comparer is not null)
63+
return Comparer.Compare(x, y);
64+
65+
if (x is string string1 && y is string string2)
66+
return Comparer<string>.Default.Compare(string1, string2);
67+
68+
return Comparer<object>.Default.Compare(x, y);
6369
}
6470

6571
/// <summary>

0 commit comments

Comments
 (0)