in reply to Re^2: hash sort
in thread hash sort

Anyway to sort without rewriting main loop ?

No. You must interpolate the code given to you into the loop argument:

foreach my $key1 ( sort { $hash2{$a}{key} cmp $hash2{$b}{key} || $a <=> $b } keys %hash1 ) {

The loop body can remain as it is, I guess.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'