BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
<syncfusion:SfDataGrid.SortComparers>
<Linq:SortComparer Comparer="{StaticResource Comparer}" PropertyName="ShipCity" />
</syncfusion:SfDataGrid.SortComparers> |
public class CustomerInfo : IComparer<Object>, ISortDirection
{
public int Compare(object x, object y)
{
int namX;
int namY;
if (x.GetType() == typeof(Orders))
{
namX = ((Orders)x).OrderID;
namY = ((Orders)y).OrderID;
}
else if (x.GetType() == typeof(Group))
{
namX = ((Group)x).Key.ToString().Length;
namY = ((Group)y).Key.ToString().Length;
}
else
{
namX = x.ToString().Length;
namY = y.ToString().Length;
}
if (namX.CompareTo(namY) > 0)
return SortDirection == ListSortDirection.Ascending ? 1 : -1;
else if (namX.CompareTo(namY) == -1)
return SortDirection == ListSortDirection.Ascending ? -1 : 1;
else
return 0;
}
private ListSortDirection _SortDirection;
public ListSortDirection SortDirection
{
get { return _SortDirection; }
set { _SortDirection = value; }
}
} |