<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><div style="font-family: courier new,monospace;" class="gmail_quote">On Wed, May 6, 2009 at 1:15 PM, John Macdonald <span dir="ltr"><<a href="mailto:john@perlwolf.com">john@perlwolf.com</a>></span> wrote:<div>
</div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><div class="h5">Since the numbers are the only significant content of the oid,<br>
</div></div>
I wonder whether it would be cheaper to recreate it at the end.<br>
Sorting with no sort function is faster than having to do<br>
2 array subscripts for each compare. (Maybe that was what<br>
abram_packsort did?)<br>
<br>
sub jmm {<br>
return<br>
map { join( '.', unpack('N*', $_) ) }<br>
sort<br>
map { pack('N*', split(/\./, $_) ) }<br>
@_;<br>
}<br>
<br>
Instead of a 2-element array, I sometimes just use a single<br>
string, consisting of a leading portion which is directly<br>
sortable, if necessary a marker, and finally the original<br>
string. The final map just removes the leading string (and<br>
the marker).<br>
</blockquote></div><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">OK... We have a new leader!<br><br style="font-family: courier new,monospace;">
</span><span style="font-family: courier new,monospace;">John is now in the lead and has passed the competition with<br>the fastest,</span><span style="font-family: courier new,monospace;"> and arguably fairly readable version provided.</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">The benchmark places it (with other versions removed for clarity):</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> s/iter Improvement</span><span style="font-family: courier new,monospace;"><br>abram_whilecmp 7.08 --</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fulko_sort 1.11 537%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">abram_nounpacksort 0.907 681%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">jmm 0.803 782%</span><br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;">