in reply to Re: Re: sorting hashes by value
in thread sorting hashes by value

While samtregar is right in his method for keeping the keys and values together, you probably don't need to go to that trouble. Why not just do something like this:
@words = sort { $word_list{$a} <=> $word_list{$b} } keys %word_list; foreach $word (@words) { print "word $word = $word_list{$word}\n"; }
@words is already a sorted list of the keys in %word_list. Of course, this assumes that nobody is doing pesky things like adding to %word_list between the time you sorted it and the time you decided to print it.