#!/usr/bin/perl use strict; # https://perlmonks.org/?node_id=11141469 use warnings; use List::AllUtils qw( nsort_by ); my $pchr = 'KQRBNP'; my $w1 = 'QRKPNB'; my $w2 = join '', nsort_by { index $pchr, $_ } split //, $w1; print "Given pchr = $pchr, then $w1 -> $w2\n";
In reply to Re: Sort list by position of items in another list
by tybalt89
in thread Sort list by position of items in another list
by gflohr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |