Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: sort mechanism

by ChOas (Curate)
on Apr 06, 2001 at 13:01 UTC ( [id://70435]=note: print w/replies, xml ) Need Help??


in reply to sort mechanism

Hi!

I hope this helps, this is what happens:

1: keys %Hash returns a list of all the keys in the hash
2: sort sorts that list
3: The foreach goes over the sorted list, presenting you the keys
of the hash in sorted order

foreach $key (sort{($a)<=>($b)} keys %hash)
is a perfectly valid way to get a list of the keys of the hash in
a sorted order (provided they are numeric)

btw the block that you mentioned does not operate on the hash
in any real sense, you use the keys of the hash in there
and yes, you can use those to access the hash.

GreetZ!,
    ChOas

print "profeth still\n" if /bird|devil/;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-24 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found