How do I setup my ICompare to sort on two properties?
/// <summary>
/// Compares two objects and returns a value indicating whether one is less
than, equal to or greater than the other.
/// </summary>
/// <param name="x">UserName</param>
/// <param name="y">UserName</param>
/// <returns></returns>
public string Compare(object x, object y)
{
UserName UserName X = (UserName )x;
UserName MapItemY = (UserName )y;
switch (m_Column)
{
case UserName .UserName SortColumns.FNameLName:
{
switch (m_SortOrder)
{
case Common.SortOrderTypes.Ascending:
//Not sure how to setup the compare to compare two properties
return UserNameX.?.CompareTo(UserNameY.?);
case Common.SortOrderTypes.Descending:
return UserNameY.?.CompareTo(UserNameX.?);
}
break;
}
case MapItem.MapItemSortColumns.LNameFName:
{
switch (m_SortOrder)
{
case Common.SortOrderTypes.Ascending:
//Not sure how to setup the compare to compare two properties
return UserNameX.?.CompareTo(UserNameY.?);
case Common.SortOrderTypes.Descending:
return UserNameY.?.CompareTo(UserNameX.?);
}
break;
}
}
return UserNameX.ItemKey.CompareTo(UserNameY.ItemKey);
}
}