On 11-08-07 11:46 AM, Ramprasad Prasad wrote:
I used a mysql database , but the order by clause used to hang the
process indefinitely
If I sort files in smaller chunks how can I merge them back ??


Please use "Reply All" when responding to a message on this list.

You need two temporary files and lots of disk space.

1. Open the first and second sorted files.
2. Read one record from each.
3. Write the lesser record to the first temporary file.
4. Read another record from the file where you got the record you wrote.
5. If not eof, goto 3.
6. Write the remaining of the other file to the end of the temporary file.

Repeat the above with the first temporary file and the third sorted file, writing the result to the second temporary file.

Repeat the above with the second temporary file and the fourth sorted file, writing the result to the first temporary file.

And so on...

Rename the final temporary file to your sorted file name.


--
Just my 0.00000002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

"Make something worthwhile."  -- Dear Hunter

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to