in reply to Re^3: Sorting Alphanumeric Arrays
in thread Sorting Alphanumeric Arrays

oops... the problem was using a regular expresion to extract the keys, try
use Sort::Key::Maker sort_num_str => sub { int($_), $_ }, qw(int str);
this way I got...
salva@cabo:/tmp$ perl /tmp/skm.pl 100 Rate GRT sort S::K::M GRT 945/s -- -2% -26% sort 967/s 2% -- -25% S::K::M 1282/s 36% 33% -- salva@cabo:/tmp$ perl /tmp/skm.pl 1000 Rate sort GRT S::K::M sort 61.0/s -- -20% -40% GRT 75.8/s 24% -- -25% S::K::M 101/s 66% 34% -- salva@cabo:/tmp$ perl /tmp/skm.pl 100000 s/iter sort GRT S::K::M sort 3.38 -- -43% -49% GRT 1.92 76% -- -10% S::K::M 1.73 96% 11% --

update: benchmark results were wrong!

Replies are listed 'Best First'.
Re^5: Sorting Alphanumeric Arrays
by BrowserUk (Patriarch) on Jun 14, 2005 at 00:11 UTC

    Nice module. I especially like the in-place options.

    A couple of questiosn I haven't been able to answer from the POD:

    • What is the difference between types 'int' & 'integer', 'num' & 'number'?
    • Does the module respect magic?

    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
    "Science is about questioning the status quo. Questioning authority".
    The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.
      What is the difference between types 'int' & 'integer', 'num' & 'number'?

      nothing, they are synonymous.

      Does the module respect magic?

      yes... though overloaded operators '<=>' and 'cmp' are not used. Overloaded keys are converted to the requested type via '""' or '0+' and then compared as raw integers, floats or strings.