Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: SORT ASSOC ARRAY

by snax (Hermit)
on Oct 09, 2003 at 20:24 UTC ( [id://298098]=note: print w/replies, xml ) Need Help??


in reply to Sort assoc array

Like ChrisR above, but this will let you get the values sorted.

First, numerically:

for my $x(sort {return $hash{$a} <=> $hash{$b}} keys %hash) { print "$x = $hash{$x}\n"; }
and now lexicographically
for my $x(sort {return $hash{$a} cmp $hash{$b}} keys %hash) { print "$x = $hash{$x}\n"; }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 09:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found