Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: how to put hash key and value in order

by Athanasius (Chancellor)
on Dec 20, 2012 at 02:56 UTC ( #1009675=note: print w/replies, xml ) Need Help??


in reply to how to put hash key and value in order

This is an FAQ, see How do I sort a hash (optionally by value instead of key)?.

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

  • Comment on Re: how to put hash key and value in order

Replies are listed 'Best First'.
Re^2: how to put hash key and value in order
by LanX (Chancellor) on Dec 20, 2012 at 03:01 UTC
    Have to say, this solution

          my @keys = sort { $hash{$a} <=> $hash{$b} } keys %hash;

    is better than mine, cause it tolerates duplicated values! :)

    Cheers Rolf

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009675]
help
Chatterbox?
[Copacetic]: I'm a new user. If I select "submit" for a new question it goes to a "Permission Denied" page. Why is this?

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2017-05-25 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?