Re: sorting of text file
- From: Joseph M. Newcomer <newcomer@xxxxxxxxxxxx>
- Date: Wed, 28 Nov 2007 11:12:20 -0500
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:
Joseph M. Newcomer [MVP]I would read the whole file in to a std:vector or CStringArray and justExcept if your file has something like 4 GB :-)
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.
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.
- Follow-Ups:
- Re: sorting of text file
- From: Mihai N.
- Re: sorting of text file
- References:
- sorting of text file
- From: petra980
- Re: sorting of text file
- From: Tom Serface
- Re: sorting of text file
- From: Mihai N.
- sorting of text file
- Prev by Date: Re: MFC dll and exe porting to 64-bit
- Next by Date: Re: How useful is GUI Scripting?
- Previous by thread: Re: sorting of text file
- Next by thread: Re: sorting of text file
- Index(es):
Relevant Pages
|
Loading