Array and Insertion Sorting in C#

F

Franky, Mondestin

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
 
J

Jon Skeet [C# MVP]

Franky said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top