We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

String sorting behavior

Sorting a grid column of the following values: "cost", "comm", "coop", and "co-op" shows that the hyphen is being ignored. This is the designed behavior of String.Compare. What I need is the behavior of String.CompareOrdinal, which treats hyphen as just another character. How do I override the default behavior to accomplisth this?

Ideally, can I override this at a level that affects all string columns of all grids?

1 Reply

RP Rekha P Syncfusion Team August 21, 2009 12:14 PM UTC

Hi Ron,

Thank you for your interest in Syncfusion Products.

Custom sorting enables you to implement custom sorting logic if the standard sorting techniques don't meet your requirements. You can add a custom IComparer to the GridSortColumnDescriptor for this column. You do this by setting the Comparer property on the GridSortColumnDescriptor. In your custom IComparer object, you can sort based on any criteria you choose including any color criteria on the record value.

The Comparer object allows you to control how the sorting is done on your column. Once the column is sorted, the custom Categorizer is used to determine which adjacent records in the sorted column belong to the same group. To create custom Comparer and Categorizer objects, you define classes that implement IComparer.

Refer the online sample below which portrays the custom sorting feature.

http://samples.syncfusion.com/ASPNET/7.3.0.20/web/Grid.Grouping.Web/samples/3.5/SortingandGrouping/BasicSorting/cs/customsorting.aspx

Please let me know if you have any concerns.

Thanks,
Rekha

Loader.
Live Chat Icon For mobile
Up arrow icon