my %hash = ( hello => 1, world => 2, perl => 3, computer => 4 ); my @array = ("hello", "world", "perl", "computer"); my @array1 = sort { $hash{$a} <=> $hash{$b} } @array;