for my $key (reverse sort keys %hash) { print "\n$key chars\n"; foreach my $element (@{$hash{$key}}) { print "$element"; } print "\n"; }