#insert HoH here @temp_array = (); for $i (keys(%HoH)) { #the name must be kept with the subhash. $HoH{$i}{"name"} = $i; push @temp_array, $HoH{$i}; #updated:transposition error on my part } #sort the temp array by decreasing head counts @temp_array = sort {$$b{"head_count"} <=> $$a{"head_count"}} @temp_array; for $i (@temp_array) { print "$$i{'name'} House Type: $$i{'house_type'} Head Count $$i{'head_count'}\n"; }