in reply to Sort problems
my @array = qw(a1_2 a1_1 a10_10 a2_10 a2_1 a2_2 a10_1 a10_2 a1_10); my @sorted = map { $_->[0] } sort {$a->[1] <=> $b->[1] } map { my $v = $_; tr/a_/0./; [$v, $_] } @array;
Make a float pair for each element of the array. Substitute 'a' with 0, and '_' with floating point '.'. Then sort the pairs by numbers and take original elements from sorted pairs
|
|---|