How to read and write the file for sorting the string names in source file and want to write it on target file in C# using Windows Form Application ?
* The Source file(*.txt) was already created and it contains
Hockey
BAsketball
Football
Tennis
Cricket
* I want to read a source file using streamwriter and also sort the strings in alphabetically
* That sorted string values write on the another target file(*.txt) using streamwriter
plz help this.....
Thanks !!

Iftikar HussainRank #423 · 5.9K reputationPosted Jul 18, 2013, 8:56 PM EDT
Try like this
Regards,
Iftikar
Vijay134 reputationPosted Jul 18, 2013, 9:16 PM EDT
thank u very much Iftikar...
Is this possible to sort without using any sorting methods.....
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 18, 2013, 9:22 PM EDT
Regards,
Iftikar
Vijay134 reputationPosted Jul 18, 2013, 9:50 PM EDT
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 18, 2013, 9:59 PM EDT
Regards,
Iftikar
Vijay134 reputationPosted Jul 19, 2013, 1:14 AM EDT
I tried that code like....
When i browse and select that source file , the file was selected. After that i want to sort which was i selected file. After that i want write on another file which was sorted strings.
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 19, 2013, 1:30 AM EDT
Regards,
Iftikar
Vijay134 reputationPosted Jul 19, 2013, 2:05 AM EDT
Plz let me know one thing....
Instead of using
if (String.Compare(data[j- 1], data[j]) > 0)
string temp = data[i - 1];
You used....
if (((IComparable)data[j - 1]).CompareTo(data[j]) > 0)
what is use of IComparable and why you used object for temp var ?
difference between IComparable and String.Compare ?
Iftikar HussainRank #423 · 5.9K reputationPosted Jul 19, 2013, 2:47 AM EDT
The role of IComparable is to provide a method of comparing two objects of a particular type. This is necessary if you want to provide any ordering capability for your object.
Regards,
Iftikar