my $VERY_LARGE_NUMBER = 999999999; sub index_of { my ( $item, @array ) = @_; my $i = 0; while ( $i < @array ) { return $i if ( $array[$i] eq $item ); $i++; } return $VERY_LARGE_NUMBER; } # Use the Schwatz, luke! @sorted = map { $_->[1] } sort { $a->[0] <=> $b->[0] } map { [ index_of( $_, @order ), $_ ] } @to_be_sorted;