in reply to Helping with sorting
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)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: (jeffa) Re: Helping with sorting
by kiat (Vicar) on Apr 02, 2003 at 05:37 UTC | |
|
Re: (jeffa) Re: Helping with sorting
by aquarium (Curate) on Apr 03, 2003 at 12:36 UTC | |
by jeffa (Bishop) on Apr 03, 2003 at 16:06 UTC |