foreach my $table (sort keys %tables) { my $href = $fields{$table}; foreach my $field (sort $href->{Position}{$a} <=> $href->{Position}{$b}} keys %$href) { print "$table -> $field\n"; } }