in reply to Re: Re: sorting hashes by value
in thread sorting hashes by value
@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.@words = sort { $word_list{$a} <=> $word_list{$b} } keys %word_list; foreach $word (@words) { print "word $word = $word_list{$word}\n"; }
|
|---|