Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: sorted Hash

by vinoth.ree (Monsignor)
on Aug 22, 2015 at 15:58 UTC ( [id://1139529]=note: print w/replies, xml ) Need Help??


in reply to sorted Hash

You need numerical sort, try the following

for $key ( sort {$a<=>$b} keys %hash) { print "($key)->($hash{$key})\n"; }

In your way with foreach

foreach (sort { $a <=> $b } keys(%SRV) ) { print"$_: "."$SRV{$_}"; }
Update:

foreach code added


All is well. I learn by answering your questions...

Replies are listed 'Best First'.
Re^2: sorted Hash
by intoperl (Acolyte) on Aug 22, 2015 at 16:04 UTC

    Thanks Vinoth, that was quick and my silly thing resolved. Everyone is so awesome here..

      Do you understand why that worked? If not, have you looked it up in the documentation?

      The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1139529]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2024-03-29 12:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found