use strict; use warnings; my %foo = ( 11 => { '4'=>'Four', }, 33 => { '1'=>'One', }, 2 => { '2' => 'Two', }, ); my $ref_HoH = \%foo; for my $k ( sort { $a <=> $b } keys %$ref_HoH ) { print "$k\n"; }