It you want to sort anything in Perl fast, then go for Sort::Key!!!
use Sort::Key::Multi qw(ii_keysort); ... my %methods = ( ... skm => sub { my @sorted = ii_keysort { (split m{,}, $_, 3 )[ 1, 0 ] } @{$_[0 +]}; return \@sorted } );
That's what I get on my computer:
Rate nSubSplit nSubRegex nSubSplit3 stSplit stSplit3 stRe +gex grtSplit grtRegex grtSplit3 skm nSubSplit 21.7/s -- -54% -61% -75% -83% - +84% -85% -91% -91% -95% nSubRegex 47.6/s 119% -- -14% -46% -63% - +65% -67% -80% -81% -89% nSubSplit3 55.6/s 156% 17% -- -36% -56% - +60% -62% -77% -77% -87% stSplit 87.5/s 303% 84% 57% -- -31% - +36% -40% -64% -64% -80% stSplit3 127/s 486% 167% 129% 45% -- +-8% -12% -48% -48% -70% stRegex 138/s 534% 189% 147% 57% 8% + -- -5% -43% -44% -68% grtSplit 145/s 569% 205% 161% 66% 14% + 6% -- -40% -41% -66% grtRegex 243/s 1021% 411% 338% 178% 91% +77% 68% -- -1% -43% grtSplit3 245/s 1029% 415% 341% 180% 93% +78% 69% 1% -- -43% skm 431/s 1885% 805% 674% 393% 239% 2 +13% 197% 77% 76% --

In reply to Re^5: numeric sort on substring by salva
in thread numeric sort on substring by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.