in reply to How can I sort my array numerically on part of the string?
Use the function nsort_by in the module List::SomeUtils.
use strict; use warnings; use List::SomeUtils qw(nsort_by); my @list = ( '1,cat', '2,dog', '22,mouse', '11,eel', '001,elk', '13,mi +nk'); my @sorted = nsort_by {/0*(\d+)\,/;$1} @list; {local $" = q(', '); print qq('@sorted'\n);}
OUTPUT:
'1,cat', '001,elk', '2,dog', '11,eel', '13,mink', '22,mouse'
Bill
|
---|
In Section
Seekers of Perl Wisdom