Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Re: Some advice regaring sorting and hashes

by targetsmart (Curate)
on Jun 08, 2009 at 11:55 UTC ( #769473=note: print w/replies, xml ) Need Help??

in reply to Some advice regaring sorting and hashes

you can use hash of arrays for that
if your data is like this
the inner array is [count, alpha, omega] respectively.
$VAR1 = { 'a' => [ 0, 1, 2 ], 'b' => [ -1, 3, 4 ], 'c' => [ 4, 5, 6 ] };
you can use something like below if you want to sort numerically by count
sort { $hash{$a}[0] <=> $hash{$b}[0]} keys %hash

-- In accordance with the prarabdha of each, the One whose function it is to ordain makes each to act. What will not happen will never happen, whatever effort one may put forth. And what will happen will not fail to happen, however much one may seek to prevent it. This is certain. The part of wisdom therefore is to stay quiet.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://769473]
[Discipulus]: good night monks!
[shmem]: LanX: oh... now I have to figure out if this is good or bad news.
LanX bad day monks ?
[LanX]: hope you find sleep
[shmem]: LanX: which one?
[LanX]: the last
Discipulus yes a very bad day
[shmem]: grandola, vila morena
[shmem]: LanX: ah, that one. You'll get the bug reports also :P
[Discipulus]: upvote me! i'll make pm great again! ;=)

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2017-04-29 22:43 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (534 votes). Check out past polls.