Click here to Skip to main content
15,064,915 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi All,

I will be highly obliged if you could solve my issue.

The issue which I am facing that is about the sorting order of the Special Chars, Numbers and Alphbets.

I think default sorting is Special Chars -> Numbers -> Alphbets in Ascending order. Suppose I have below data

"Test1","12234","23","@abc","@123"

if we sort the above data in c# in ascending order then we will get the following result

"@123","@abc","12234","23","test1"


But as per my requirement , I want the sorting to be Numbers -> Special Chars ->Alphabets

The above result should come as

"12234","23","@123","@abc","test1"




And these results I am displaying in the DataGrid, So I want to change the way of default sorting of the grid so that the above result can be achieved.



Thanks in advance.
Posted
Updated 8-Apr-14 9:58am
v2
Comments
   
To talk about sorting, you really need to indicate what is the data set, what is used for its container (collection), what library type are you using, and so on.
—SA
dharam_hbtik 8-Apr-14 15:40pm
   
Thanks Sergey for quick response.
To clarify your doubt , I am getting data from service in array in the sorted order (Order is Numeric->Special Chars -> Alphabets) and When I am binding this array to my grid in which the sorting is ON by default then it automatically sorts the data in the order Special Chars-> Numbers -> Alphabets

1 solution

Use the Link OrderBy method - it allows you to specify the sort order for the strings yourself: http://msdn.microsoft.com/en-us/library/bb549422.aspx[^]
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900