in reply to Sorting hash

To answer your second question
$dd{'1'}{'2'}{'3'}="hi";
is equivalent to
my %dd = ( 1 => { 2 => { 3 => 'hi' } } );
and %{$dd{'1'}} is equal to ( 2 => { 3 => 'hi' } ). To get the value you assign it to a scalar and then dereference the keys of that hash ref.
my $hash_ref1 = $dd{1}; print $hash_ref->{2}{3}, "\n"; # prints h1
or if you are iterating over a structure
while ( my ( $key, $hash_ref ) = each ( %{ $dd{1} } ) { # $key == 2 # $hash_ref == { 2 => { 3 => 'hi' } } }