Sort::MergeSort - merge pre-sorted input streams
use Sort::MergeSort; my $terator = mergesort($comparefunc, @iterators);
Given a comparison function and a bunch of iterators that produce data that is already sorted, mergesort() will provide an iterator that produces sorted and merged data from all of the input iterators.
mergesort()
Sort::MergeSort also works with filehandles. It doesn't care. If it's only input is a filehandle, it will return a filehandle. In all other situations it will return an iterator.
The $comparefunc takes two arguments. It does not use the implicit $a & $b that perl sort uses.
$comparefunc
$a
$b
The iterators are treated as file handles so any filehandle or Sort::MergeSort::Iterator will do as input.
use Sort::MergeSort;
Sort::MergeSort::Iterator
To install Sort::MergeSort, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sort::MergeSort
CPAN shell
perl -MCPAN -e shell install Sort::MergeSort
For more information on module installation, please visit the detailed CPAN module installation guide.