As tall_man said, this is a typical situation of merge sort. You can try the module given by tall_man.
The other approach is to do the merge sort by yourself.
First sort each file needs to be merged, sounds like you have program for this already.
Have your own merge sort program do this (for example you are trying to merge n files),
open all n files you want to merge
open output file for merged result
read one line from each of those n files
compare those lines, and write out the smallest one
if a line has been written out in step 4, then read next line from that file, if eof, close that file.
goto 4, unless all file closed, i.e. finished (there is some subtle thing here, make sure that after all file closed, you still write out all the left over lines already read in)
This algorithm only holds n lines at the most, memory usage is carefully designed.
Another approach is to have a single script running as log server, and all your monitors just send logs to that server thru UDP, in this way the log msgs would be in order from the beginning.
I used this approach in a real telecomminucation system, and yet speed is not a problem.
But you have to spend some time on the log server, carefully lay out things like block writing etc.