Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
Excel-style sorting algorithm
posted

Hi,

I want to use Excel-style soring for my text column  so that it sorts values as 1,2,..10,11 instead of 1,10..2,20.. as would be the default for test sorting.

 

Thanks in advance

 

Regards

Habib

Parents
No Data
Reply
  • 45049
    Verified Answer
    posted

    You have two options.

    The first and easiest is to use a numeric datatype, such as int or double, for the data in the underlying grid column.  By default, the grid will sort using the IComparable implementation of the data type, so numbers get sorted as numbers and strings as strings.

    The other way, more powerful but requiring more code to accomplish, is to implement your own SortComparer.  The API documentation for the SortComparer property of the UltraGridColumn class (from the online help documentation for NetAdvantage for .NET 2008 Volume 3) provides more detail and a simple example implementation.

Children