Click to See Complete Forum and Search --> : Sorting


April 6th, 1999, 04:11 PM
what is the best way to sort 10 million strings, taking into account space & speed constraints . It takes about 5 hours for me now using a UNIX tool..

Torkel
April 6th, 1999, 08:15 PM
How are they stored?
*) in memory?
*) in flat file on hard disk?
*) in database?

Masaaki
April 6th, 1999, 09:37 PM
Hi.

When I took C++ class, my professor told us this.
When we want to sort the data, it is better for us to sort
something whenever we input the data. Otherwise, the sorting time
brings us to waste the time.

In your case, the huge data already exists.
It can't be helped.
Next time, you had better change your program.

Regards.
-Masaaki Onishi-

April 7th, 1999, 01:16 PM
this would be in a file in the hard disk.
The sorting involves strings. Please suggest an efficient method

Luypaert Benny
April 7th, 1999, 07:59 PM
try the quicksort rountine or try this :
first open a second file, then read the first string in, second insertion starts to compare with a while loop, enz...
close your file and delete the original and
rename your second file to the first file.

and try to keep your date in memory if you can.
only at the last moment save it...

hope this helps

Luypaert Benny

May 16th, 2000, 11:42 AM
Hi,

The best possible sort for that much data is the Radix Sort routine. The problem is getting the data from the flat file into memory. I would read the first key into a memory holder and us the file pointer to move up and down the flat file. I hope this helps. ;-)

Later
Ken