$ perl -E ' my %x = (A=>{h=>2}, B=>{h=>1}, C=>{h=>3}); say for sort { $x{$b}{h} <=> $x{$a}{h} } keys %x; ' C A B