http://www.perlmonks.org?node_id=11106287


in reply to How to Order an Array's Elements to Match Another Array's Element Order

Create a hash to map name to index and use that to sort.
my %index; @index{@array} = 0..$#array; my @result = sort { $index{$a} <=> $index{$b} } @subset;

Dave.

  • Comment on Re: How to Order an Array's Elements to Match Another Array's Element Order
  • Download Code