Dear All,
I have a column of string data type and having numerical value -1,0,1 and if i try to sorting ascending, it was display as 0,1,-1 but expected is -1,0,1. In this case only all the value are numerical but most of the case it will have combination of numeric,string and special character.
when i compare the same behavioue with excel it was working fine. How to achieve the excpected result.
Regards
Vijay A
Hi Vijay,
If the data is stored as a string, then it will be sorted as a string. The best thing to do would be to use a numeric type instead of strings.
If you cannot do that, then you could use the SortComparer property on the column to sort the data in a custom order. What you have to do is write a class that implements the IComparer interface. There are lots of examples of this here on the forums for all sorts of custom sorting requirements.
Hi Mike,
Thanks for the reply. i cannot convert the data type to numeric type since the column has to support alpha numeric and special characters. I have tried to implement the ICompare interface for sorting. In the compare method i have implemented the following logic.
Xcell.Value.ToString.CompareTo(YCell.Value.ToString());
Expected behavior:
There should not be a difference in sorting the string value in excel and in ultra wingrid.
It would be great if you let me know how to achieve the string sorting in ultra win grid as in excel.