http://www.perlmonks.org?node_id=1008198


in reply to Accessing or printing key and value

The way you are loading your hash looks odd. I suggest putting something this into your loop: $ARG{$tab1} = $tab2; instead of push(@ {$ARG{"$tab1"}},"$tab2");. (EDIT: nevermind about that, I just realized you are going for a hash of arrays) Also, be sure to include use warnings; use strict;, if you aren't already doing so.

As I understand it, the column you want to sort by is also the key, right? If so, change foreach  $string  (keys %ARG) { to foreach $string ( sort keys %ARG ) { (otherwise, the order will be 'random').