Articles in this section
Category / Section

How to make the Numeric Sorting possible

1 min read

Pivot Grid will populate the data in ascending order by default with numeric string sorting. However, we suggest you to use the custom comparer to arrange the Pivot Row values with the numeric sorting. You can use the below code snippet to arrange Pivot Row values with the numeric sorting


public MainWindow()
this.DataContext = new ViewModel();
this.grd.PivotRows.Add(new PivotItem { FieldMappingName = "Day", TotalHeader = "Total", Comparer = new MyComparer() }); 
public class MyComparer : IComparer
#region IComparer Members
public int Compare(object x, object y)
if (x == null && y == null)
return 0;
else if (y == null)
return 1;
else if (x == null)
return -1;
return int.Parse(x.ToString()).CompareTo(int.Parse(y.ToString()));


Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment