http://qs321.pair.com?node_id=11124461

misterperl has asked for the wisdom of the Perl Monks concerning the following question:

I have this array:

my @list = ( '1,cat', '2,dog', '22,mouse', '11,eel', '001,elk', '13,mink');

that I'd like to sort numerically based on the number in front of the comma, so I tried:

print join "\n", sort { ($a=~s/,.+//) <=> ( $b =~ s/,.+// ) } @list;

But I seem to get an alpha, non-numeric result, which has the added detriment of dropping off my animals...

1 2 22 11 001
I also tried approaches like  "\A\d+$a" <=> "\A\d+$b" which the interpreter REALLY hated!

TY Wise ones.