<span style="font-family: courier new,monospace;">Thanks all for your ideas.<br><br>I've coalesced the various suggestions (excluding Uri's comments so far)<br>and present for your amusement, the following results based on my<br>
'real-world' dataset of 24,528 OID strings.<br><br> s/iter</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">abram_whilecmp 7.30 --</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">indy_slow_sort 7.11 3%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">indy_fast_sort 6.53 12%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">henrys_sort 5.06 44%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">fulko_sort_optimized 1.77 314%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">fulko_sort_orig 1.72 323%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">abram_swartzpacksort 1.60 357%</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">abram_packsort 1.48 392%</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">abram_nounpacksort 0.96 660%</span><br style="font-family: courier new,monospace;">
<br style="font-family: courier new,monospace;"><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;">Note: I had to alter Indy's 'slow' compare because %3d is not large<br>
enough for real data. The numbers can range from 0 to 4 Gig.<br>This also means that Indy's fast compare won't work either.<br><br>As it turns out, my original code doesn't appear to be all that<br>bad after all. But as I went through and thought I was optimizing<br>
it with maps and stuff, it actually gets worse.<br><br>Both my original code, and my optimized version is provided below for<br>peer review. In the mean time, I may just investigate </span><span style="font-family: courier new,monospace;">the 'nounpacksort'<br>
version.<br><br>sub fulko_sort_orig {<br> my @oids = @_;<br><br> my ($i, @r1, $temp);<br> my $len = scalar(@oids);<br> for ($i = 0; $i < $len; $i++) {<br> $temp = '';<br> @r1 = split(/\./, $oids[$i]);<br>
foreach (@r1) { $temp .= sprintf ("%8d.", $_); }<br> chop($temp);<br> $oids[$i] = $temp;<br> }<br> @oids = sort @oids;<br> for ($i = 0; $i < $len; $i++) {<br> $oids[$i] =~ s/ //g;<br>
}<br> @oids;<br>}<br><br>sub fulko_sort_optimized {<br> my @oids = sort<br> map { join ".",<br> map { sprintf ("%8d", $_); } split /\./;<br> } @_;<br>
<br> for (my $i = 0; $i < scalar(@oids); $i++) {<br> $oids[$i] =~ s/ //g;<br> }<br> @oids;<br>}<br><br style="font-family: courier new,monospace;"></span><br style="font-family: courier new,monospace;">