sort a text file?

  • Thread starter Thread starter Trint Smith
  • Start date Start date
T

Trint Smith

ok, this txt file list is the contents of a file called TextFiles.txt:

030828700BatchGroup.txt
030828700Catalog.txt
030828700Images.txt
030828700Item.txt
030828700ItemSold.txt
030828700Program.txt
030828700Seller.txt
030828702BatchGroup.txt
030828702Catalog.txt
030828702Images.txt
030828702Item.txt
030828702ItemSold.txt
030828702Program.txt
030828702Seller.txt
030828701BatchGroup.txt
030828701Catalog.txt
030828701Item.txt
030828701ItemSold.txt
030828701Program.txt
030828701Seller.txt
030828702BatchGroup.txt
030828701Images.txt

how can i sort these lines and keep each one that has a matching end
name?? each order number (first part of the file name) is always gonna
have these names associated with it'Program.txt', 'BatchGroup.txt',
'Catalog.txt', 'Item.txt', 'ItemSold.txt', 'Seller.txt' and 'Images.txt'
is there an easy way to do this or am i gonna have to plan on a day or
two of coding?
thanks,
Trint


..Net programmer
(e-mail address removed)
 
Hello,

Trint Smith said:
ok, this txt file list is the contents of a file called TextFiles.txt:

030828700BatchGroup.txt
030828700Catalog.txt
030828700Images.txt
030828700Item.txt
030828700ItemSold.txt
030828700Program.txt
030828700Seller.txt
030828702BatchGroup.txt
030828702Catalog.txt
030828702Images.txt
030828702Item.txt
030828702ItemSold.txt
030828702Program.txt
030828702Seller.txt
030828701BatchGroup.txt
030828701Catalog.txt
030828701Item.txt
030828701ItemSold.txt
030828701Program.txt
030828701Seller.txt
030828702BatchGroup.txt
030828701Images.txt

how can i sort these lines and keep each one that has a matching end
name?? each order number (first part of the file name) is always gonna
have these names associated with it'Program.txt', 'BatchGroup.txt',
'Catalog.txt', 'Item.txt', 'ItemSold.txt', 'Seller.txt' and 'Images.txt'
is there an easy way to do this or am i gonna have to plan on a day or
two of coding?

You can load the file into a string array (StreamReader.ReadLine, have a
Google Groups Search on that) and sort it by calling its Sort method. Maybe
you need a structure for storing the items (number, filename) and implement
a custom comparison routine (like
http://www.mvps.org/dotnet/dotnet/samples/codingtechnique/ ->
"CompareOperator").

HTH,
Herfried K. Wagner
 
thanks,
i think an array will work nicely.
trint

.Net programmer
(e-mail address removed)
 
Back
Top