|
|
| Think about Loose Coupling | |
| PerlMonks |
Re^2: Evolving a faster filter? (sort)by tye (Cardinal) |
| on Jan 04, 2013 at 21:10 UTC ( #1011720=note: print w/ replies, xml ) | Need Help?? |
|
Heh, I just had what might be a great idea on how to do the first sort. It is trivial to do a two-item optimization in your sort comparison routine. This is "cheating" because you can end up telling sort that you want $a < $b and $b < $c but $c < $a. On old versions of Perl, that might even cause a core dump. I think it is actually documented as safe on modern Perl, however.
It is that simple. It worked reasonable well in a couple of test cases. It even found an optimal solution on the first try for my prior example above (but took too long to declare success, probably indicating a bug). - tye
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||||||