in reply to Sorting on multiple variables
sort { my ($a1,$a2,$a3) = $a =~ /(\d*)_FFF(\d*)_(\d*)/; my ($b1,$b2,$b3) = $b =~ /(\d*)_FFF(\d*)_(\d*)/; $a1 <=> $b1 || $a2 <=> $b2 || $a3 <=> $b3 }
Update: If you want to avoid the redundancy:
map $_->[0], sort { $a->[1] <=> $b->[1] || $a->[2] <=> $b->[2] || $a->[3] <=> $b->[3] } map [ $_, /(\d*)_FFF(\d*)_(\d*)/ ],
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Sorting on multiple variables
by hobbs (Monk) on Jul 23, 2009 at 09:59 UTC | |
|
Re^2: Sorting on multiple variables
by cbdoc (Novice) on Jul 23, 2009 at 16:51 UTC |