Enjoy!@to_be_sorted=qw( cat bird dog tiger puma mouse ); @order=qw( mouse cat dog lion elephant ); %order=(); for($_=0; $_<@order; $_++) { $order{$order[$_]}=$_; } @sorted=sort { $order{$a}=@order unless exists $order{$a}; $order{$b}=@order unless exists $order{$b}; $order{$a}<=>$order{$b} } @to_be_sorted;
In reply to Re: Sorting an array by another array
by clintp
in thread Sorting an array by another array
by TGI
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |