You can specify, which sort method to use for sorting with perl sort function.
Please go through the following link to get to know:
http://search.cpan.org/~tty/kurila-1.14_0/lib/sort.pm
If you are running in Unix or Linux like operating system, you can use shell command "sort".
You can use Tie::File module, which will not use much memory, but this will slow down the sorting process.
| [reply] [Watch: Dir/Any] |
That's a link to sort.pm in the kurila distribution. You want the in the perl distribution: sort
You can specify, which sort method to use for sorting with perl sort function.
The point isn't to use merge sort. The point is to sort files, which merge sort can do. use sort can't help with that.
You can use Tie::File module
I don't think sort can sort tied arrays in-place, so sort would cause the entire file to be loaded into memory.
Even if sort sorts tied arrays in-place, the performance would be abysmal. We're talking about writing out (tens of? hundred of?) thousands of lines O(N log N) times.
Finally, it would use more than "not much" memory. Tie::File keeps an index of every line it has encountered in the file. That usually means, as it does in this case, that it keeps an index of every line in the file. This is in addition to the cache. That's a significant amount of memory in this case, but it sounds like it could be acceptable.
| [reply] [Watch: Dir/Any] [d/l] [select] |