Re: sorting of text file



SORT54 will always be with us!

(SORT54 was the multiway disk merge-sort IBM supplied, used in the days when we had 16,000
byte main memories but gigantic 2MB hard drives, ca. 1965)

What you do with large files is segment them by reading in a chunk that fits in memory,
sorting it, and writing it to a temp file. Repeat for temp files 0..n. Then enter merge
mode, read in n+1 lines from files 0..n, merge them by sorting them, repeat until all
files have been read. I have this code in SAIL (I was sorting 1-2MB files on a 256K
machine in those days) but I'm sure google must reveal C code that does it...
joe

On Wed, 28 Nov 2007 00:00:00 -0800, "Mihai N." <nmihai_year_2000@xxxxxxxxx> wrote:

I would read the whole file in to a std:vector or CStringArray and just
sort the lines then write them back. If you need to sort a huge file
you'll have to do it with a number of merge sort files then add then
all back together into the original.
Except if your file has something like 4 GB :-)
Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Re: A Fast sorting algorithm for almost sorted data
    ... far my compressor has potential but is nowhere near ready. ... It does however make heavy use of sorting. ... which I am currently calling Run sort. ... entire selected run can be added to the sorted output array. ...
    (comp.compression)
  • Re: Solution for sorting an array alpha-numerically
    ... strings up into groups and sorting the groups seperately, ... > so that numeric and alphabetic data sort as seperate groups. ... To the same project as the web page, add the class AlphaNumCompare() ...
    (microsoft.public.dotnet.general)
  • Re: how fast can I sort on mainframe (using DFSORT)?
    ... Since I joined the team as the performance lead a couple years ago, ... Frank now defers these types of questions to me. ... I have been out of the sorting business for a while, ... Writing to sort work files should not be the problem, ...
    (bit.listserv.ibm-main)
  • Re: except tasks from sorting
    ... position out of any sort key. ... But we will sorting subsequently. ... sort key is a Text ... hint to filtering the tasks before ...
    (microsoft.public.project)
  • Re: When random isnt random
    ... >> (and, if there is not one already, a Sorting Unit). ... TList has a Sort method. ... Try it with a TList and in the compare function ... There seems to be, sometimes, a requirement for a Shuffle that leaves ...
    (borland.public.delphi.language.objectpascal)

Loading