tags:

views:

32

answers:

1

So I have multiple files that I am working on and they need to be combined and sorted. Would it be more efficient to sort each file first and use the sort -m option when combining the files, or to combine them first and then sort.

Or is it the same? My understanding is that unix uses merge sort so in essence, would the one big file be separated, sorted, and recombined anyway? So it shouldn't make a difference?

+1  A: 

Sort the files together.

sort file1 file2 file3 file4

Unless you have a lot of time to investigate, the sort command will do a better job than you in breaking the files into appropriately-sized chunks, sort them independently and recombine them.

Paul Hankin