You need numerical sort, try the following
for $key ( sort {$a<=>$b} keys %hash) { print "($key)->($hash{$key})\n"; }
In your way with foreach
Update:foreach (sort { $a <=> $b } keys(%SRV) ) { print"$_: "."$SRV{$_}"; }
foreach code added
In reply to Re: sorted Hash
by vinoth.ree
in thread sorted Hash
by intoperl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |