my %order; $order{$order[$_]} = @order-$_ for (0..$#order); { local $^W=0; my @sorted = sort { $order{$b} <=> $order{$a} } @sortme; }