in reply to Re: Re^3: Heap sorting in perl
in thread Heap sorting in perl
I don't follow your reasoning.
We were talking at cross purposes. I thought that you were proposing to heap sort the entire dataset, not the subset of smallest elements.
I admit that my using sort to order the smallest subset is a hack, but unless N is large or the comparison function is expensive, it will be faster than a pure-perl heap.
As for overkill, using Perl to solve a problem that can be solved with the correct option to the Unix sort utility is overkill. But if you need a general purpose solution in Perl and you have a heap implementation there already, why not use it?
I don't see how the Unix sort applies. We don't want to sort the whole dataset - we want the smallest N elements (and we also don't know if the dataset consists of line oriented data.)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re^5: Heap sorting in perl
by Anonymous Monk on Apr 05, 2003 at 17:02 UTC | |
by adrianh (Chancellor) on Apr 05, 2003 at 20:12 UTC |