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
In reply to Re: sorting hash ref
by tlm
in thread sorting hash ref
by perlboer
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |