Skip to content

Commit c1e04a0

Browse files
committed
Use optional constructors parameter for comparer
1 parent 2df0f18 commit c1e04a0

File tree

1 file changed

+8
-28
lines changed

1 file changed

+8
-28
lines changed

Microsoft.Toolkit.Uwp.UI/AdvancedCollectionView/SortDescription.cs

Lines changed: 8 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -39,44 +39,24 @@ public class SortDescription
3939
/// Initializes a new instance of the <see cref="SortDescription"/> class that describes
4040
/// a sort on the object itself
4141
/// </summary>
42-
/// <param name="direction">direction of sort</param>
43-
public SortDescription(SortDirection direction)
44-
: this(null, direction, ObjectComparer.Instance)
45-
{
46-
}
47-
48-
/// <summary>
49-
/// Initializes a new instance of the <see cref="SortDescription"/> class that describes
50-
/// a sort on the object itself
51-
/// </summary>
52-
/// <param name="direction">directio of sort</param>
53-
/// <param name="comparer">comparer to use</param>
54-
public SortDescription(SortDirection direction, IComparer comparer)
42+
/// <param name="direction">Direction of sort</param>
43+
/// <param name="comparer">Comparer to use. If null, will use default comparer</param>
44+
public SortDescription(SortDirection direction, IComparer comparer = null)
5545
: this(null, direction, comparer)
5646
{
5747
}
5848

5949
/// <summary>
6050
/// Initializes a new instance of the <see cref="SortDescription"/> class.
6151
/// </summary>
62-
/// <param name="propertyName">name of property to sort on</param>
63-
/// <param name="direction">direction of sort</param>
64-
public SortDescription(string propertyName, SortDirection direction)
65-
: this(propertyName, direction, ObjectComparer.Instance)
66-
{
67-
}
68-
69-
/// <summary>
70-
/// Initializes a new instance of the <see cref="SortDescription"/> class.
71-
/// </summary>
72-
/// <param name="propertyName">name of property to sort on</param>
73-
/// <param name="direction">direction of sort</param>
74-
/// <param name="comparer">comparer to use</param>
75-
public SortDescription(string propertyName, SortDirection direction, IComparer comparer)
52+
/// <param name="propertyName">Name of property to sort on</param>
53+
/// <param name="direction">Direction of sort</param>
54+
/// <param name="comparer">Comparer to use. If null, will use default comparer</param>
55+
public SortDescription(string propertyName, SortDirection direction, IComparer comparer = null)
7656
{
7757
PropertyName = propertyName;
7858
Direction = direction;
79-
Comparer = comparer;
59+
Comparer = comparer ?? ObjectComparer.Instance;
8060
}
8161

8262
private class ObjectComparer : IComparer

0 commit comments

Comments
 (0)