PhilBayley Posted February 9, 2004 Posted February 9, 2004 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 Quote
PhilBayley Posted February 9, 2004 Author Posted February 9, 2004 Just a little note. The files can be massive so loading it into memory is not really a good option. Quote
PhilBayley Posted February 9, 2004 Author Posted February 9, 2004 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. Quote
Leaders Iceplug Posted February 9, 2004 Leaders Posted February 9, 2004 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); }; Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.