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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

String sorting behavior

Thread ID:





88992 Aug 16,2009 03:27 PM UTC Aug 21,2009 12:14 PM UTC ASP.NET Web Forms (Classic) 1
Tags: GridGroupingControl
Ron Rudman
Asked On August 16, 2009 03:27 PM UTC

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?

Rekha P [Syncfusion]
Replied On 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.


Please let me know if you have any concerns.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon