Click here to Skip to main content
15,895,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
There is a Some Problem with Sort Data in Textbox with btncmd_click in VS2008

I have Data in textbox like this

Michal Jackson<br />
Andy<br />
http://www.dreamincode.net<br />
http://www.microsoft.com<br />
http://yahoo.com<br />
001zune<br />
A one


I want to Sort Data to 0-9, A-z Like this:

001zune<br />
A one<br />
Andy<br />
http://www.dreamincode.net<br />
http://www.microsoft.com<br />
http://yahoo.com<br />
Michal Jackson


Can Any one guide me?

Can anybody give me an example?

Thanks in Advance !!
Posted
Updated 29-Jan-10 8:55am
v2

Since you didn't specify the language, you get C# from me.

Create a List<string>, add the strings to it, and use the List.Sort() method.
 
Share this answer
 
I assume your textbox is multiline.

So, you can get all the text in an string array. Then, you can make use of Array.Sort method and reset the text of the textbox with the sorted array.

In case you are using .Net 3.0 or above, you can use LINQ to sort the array (through order by keyword).
 
Share this answer
 
Comments
Member 8164209 18-Feb-12 7:30am    
Please sort string array with out inbuild funtion.
You may want to consider using a list box instead of an edit control (textbox). Check the documentation for your environment/language tool/library. Basic level win 32 api info is here[^]
 
Share this answer
 
I can guarantee that there are plenty available for sorting string array.
 
Share this answer
 

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