in reply to Sorting an HoH (Or Something?)

sort your keys by the value. Replace your second foreach line with this line.
foreach my $iid ( sort { $hash{$name}{$b} <=> $hash{$name}{$a} } keys + %{$hash{$name}}) {
Boris