http://qs1969.pair.com?node_id=11124491


in reply to How can I sort my array numerically on part of the string?

A GRT solution, in the interests of TIMTOWTDI.

johngg@abouriou:~/perl/Monks$ perl -Mstrict -Mwarnings -E ' my @list = do { no warnings qw{ qw }; qw{ 1,cat 2,dog, 22,mouse frog 11,eel 001,elk horse 002,bear 13,min +k }; }; say for map { unpack q{x54A50} } sort map { pack q{NA50A50}, ( m{^(\d+),(\S+)} ? ( $1, $2 ) : ( 0, q{} ) +), $_ } @list;' frog horse 1,cat 001,elk 002,bear 2,dog, 11,eel 13,mink 22,mouse

I hope this is of interest.

Cheers,

JohnGG