in reply to sorting hash ref
cool_jr256's post explains what's wrong with your code, so the following is a relatively minor point. There's no need to follow a the sort with reverse. Just reverse the order of the $a/$b comparison:
foreach my $sorted_url ( sort { $hash{$b}->{'hits'} <=> $hash{$a}->{'hits'} ) keys %hash ) {
Update: Revised wording slightly.
the lowliest monk
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: sorting hash ref
by salva (Canon) on Jun 10, 2005 at 14:43 UTC | |
by halley (Prior) on Jun 10, 2005 at 14:59 UTC |