@t = ( {'b','1','w','10'},{'b','3','w','30'},{'b','2','w','40'}); foreach $f1 (@t){ foreach $f2 (keys %$f1){ print $$f1{$f2},"\n"; } } @bb = sort func @t; sub func{ print ${$a}{'b'}," ",${$a}{'w'}," :"; print ${$b}{'b'}," ",${$b}{'w'}," \n"; print "xxx",(${$a}{'b'} lt ${$b}{'b'}),"xxx"; print "\n================\n"; return ${$a}{'b'} lt ${$b}{'b'}; } foreach $f1 (@bb){ foreach $f2 (keys %$f1){ print $$f1{$f2},"\n"; } }