in reply to Re: Sorting question
in thread Sorting question
that for the OP sample data is almost five times faster than Sort::Naturally:use Sort::Key::Natural qw(natsort); my @sorted = natsort @data;
outputs...use Benchmark qw(cmpthese); use Sort::Naturally qw(nsort); use Sort::Key::Natural qw(natsort); my @data = grep !/^\s*$/, <DATA>; chomp(@data); cmpthese(-10, { sn => sub { my @s = nsort @data }, skn => sub { my @s = natsort @data } } ); __DATA__ K-2-D-10A K-2-D-10C K-2-D-10D ...
$ perl bm.pl Rate sn skn sn 45.0/s -- -79% skn 216/s 381% --
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Sorting question
by jwkrahn (Abbot) on May 15, 2006 at 22:32 UTC | |
by salva (Canon) on May 16, 2006 at 17:20 UTC |