in reply to Re: hash sort
in thread hash sort

Thank you. It works. Anyway to sort without rewriting main loop ?
foreach my $key1 ( sort { $a <=> $b } keys %hash1 #main loop
Thanks

Replies are listed 'Best First'.
Re^3: hash sort
by shmem (Chancellor) on May 31, 2017 at 16:16 UTC
    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'