in reply to Re^4: Creating a hash from arrays
in thread Creating a hash from arrays

That code was suppose to sort by values
You're nearly there...
my %hash; for my $i (0 .. $#fname) { $hash{ "$fname[$i] $lname[$i]" } = $state[$i] } # sort the keys by value for my $key ( sort { $hash{$a} cmp $hash{$b} } keys %hash ) { print "$key $hash{$key}\n"; } # alternatively my @sorted = sort { $hash{$a} cmp $hash{$b} } keys %hash; for my $key ( @sorted ) { print "$key $hash{$key}\n"; }
$a and $b are special variables and are not the same as $i and $j in your example... see sort