How about a hash slice? No sorting required.
johngg@abouriou:~$ perl -Mstrict -Mwarnings -E 'say q{}; my @PCHR = qw{ K Q R B N P }; my $w1 = q{QRKPNB}; my %w1LU = map { $_ => $_ } split m{}, $w1; say join q{}, @w1LU{ @PCHR };' KQRBNP
I hope this is of interest.
Cheers,
JohnGG
In reply to Re: Sort list by position of items in another list
by johngg
in thread Sort list by position of items in another list
by gflohr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |