Update: be sure and read japhy's Resorting to Sorting. Especially the part about the Guttman Rosler transforms. (i'll leave that implementation of this particular problem as an exercise for another monk ;))use strict; use warnings; my @array = qw(2aa 2ba 12kf 9cn 9vn 21sg); my @sorted = map { join('',@$_) } sort { $b->[0] <=> $a->[0] or $a->[1] cmp $b->[1] } map { /(\d+)(\w+)/;[$1,$2] } @array ; print "$_\n" foreach @sorted; __END__ 21sg 12kf 9cn 9vn 2aa 2ba
Update2: just noticed that the map after the sort could be written more consisely as:
Update3: fixed typo (s/b->\[1/a->[1/) ... thanks Enlil :)map { [/(\d+)(\w+)/] } @array
jeffa
L-LL-L--L-LL-L--L-LL-L-- -R--R-RR-R--R-RR-R--R-RR B--B--B--B--B--B--B--B-- H---H---H---H---H---H--- (the triplet paradiddle with high-hat)
In reply to (jeffa) Re: Helping with sorting
by jeffa
in thread Helping with sorting
by kiat
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |