469,591 Members | 1,527 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,591 developers. It's quick & easy.

Array and Insertion Sorting in C#

Problem description:
I have a text file with 700 lines. Each line has 7 elements separated by
comma. My text file looks something like :
a,b,c,d,e,f,g
d,e,h,k,l,m,n
x,c,v,f,g,t,z
.... and so on

Help needed
I'd like to read this file, place it in an array, sort the array by the
second element of each line using insertion sorting, and pass the sorted
array to a class object that will do some other stuff on it.

Any help guys would be appreciated.

Thanks

Nov 16 '05 #1
1 1695
Franky, Mondestin <fm********@comcast.net> wrote:
Problem description:
I have a text file with 700 lines. Each line has 7 elements separated by
comma. My text file looks something like :
a,b,c,d,e,f,g
d,e,h,k,l,m,n
x,c,v,f,g,t,z
... and so on

Help needed
I'd like to read this file, place it in an array, sort the array by the
second element of each line using insertion sorting, and pass the sorted
array to a class object that will do some other stuff on it.


Why do you particularly care what kind of sort it uses?

I'd suggest reading each line, parsing it appropriately, then appending
it to an ArrayList. Then use ArrayList.Sort, passing in an IComparer
that compares the parsed lines in the appropriate way.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Federico G. Babelis | last post: by
2 posts views Thread by Kushal | last post: by
46 posts views Thread by RoSsIaCrIiLoIA | last post: by
14 posts views Thread by Roman Mashak | last post: by
21 posts views Thread by Jaspreet | last post: by
25 posts views Thread by Rainmaker | last post: by
3 posts views Thread by inkexit | last post: by
6 posts views Thread by routeslip | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.