use Data::Dumper; %hash = ( x=> 'line 1', z=> [ 1, 2, 4], y=> { file=> 'test.txt', length=> 200, type => 'ASCII' }, a=> 'line 2' ); foreach(sort{ $a cmp $b } keys(%hash)) { print Dumper($hash{$_}); }