Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

HI,

 

Does anyone know of a c# class or any other component to sort data within a text file. I need to sort on multiple values and even hex codes on occasion. I used to use a dll called psortnt.dll from http://www.rrsd.com but it doesnt like c# or managed c++ and I am having difficulties.

 

Hopefully someone can help.

 

PB

 

ps. typical data would be

 

00000|0002|003|92380498ksdjflk|

00005|9283|299|lkdwke|kejfls|

00001|8734|203|jklflkjslkdj|kjdflksj

 

and I would sort by characters 0-5 for instance

Posted

ok - I have sorted my problem out but would still like to know of any other way of sorting data within a file without a third party product or a database.

 

fyi

The sort dll from rrsd.com was an old version and the new one works fine with .net (the old one works fine with c++). It is the fastest thing I have found to sort data within files.

  • Leaders
Posted

Well, if I couldn't load the file to memory, I'd probably try to do something like a bubble sort... something like this if you can understand what I'm trying to do.

string Maximum, MatchLine, NetMaximum;
while (Counter != NumberOfLinesInFile) {
 Dat = "";
 MatchLine = "";
 Maximum = "";  
 while (SR.Peek != -1) {
   Dat = SR.ReadLine();
   if (Dat.Substring(0, 5).CompareTo(Maximum) > 0) {
     Maximum = Dat.Substring(0, 5);
     MatchLine = Dat;
   };
 };
 Counter++;
 SW.WriteLine(Dat);
};

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...