|
Re: sort with special order: msg#00350perl-beginners
Jo for lists and groups wrote: > How about this? Jo > #!/usr/bin/perl > > use strict; > use warnings; > > my @list = qw/dog is a there/; > my @sortOrder = (3,1,2,0); > my @sorted; > foreach (@sortOrder) { push(@sorted,$list[$_]); } > > print "@sorted"; > exit; ...or this: #!/usr/bin/perl use strict; use warnings; my @list = map { qw(dog is a there)[$_]; } qw(3 1 2 0); print "@list"; ... or all at once: print join(' ', my @list = map { qw(dog is a there)[$_]; } qw(3 1 2 0)); :) Steve
|
|
||||||||||||||||||||||||||
|
|
|
| News | Mail Home | sitemap | FAQ | advertise |