Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Sorting HOH

by ihb (Deacon)
on May 02, 2005 at 15:18 UTC ( [id://453281]=note: print w/replies, xml ) Need Help??


in reply to Sorting HOH

As ysth says your question is a bit vague. Anyway, here's an approach that you can start to work with.

use Hash::Flatten qw/ flatten unflatten /; sub pair { ... } # 1,2,3,4 => [1,2],[3,4] my %data; $data{1} = {'a' => 10, 'b' => 5, 'c' => 20 }; $data{2} = {'a' => 90, 'b' => 15, 'c' => 40 }; my @sorted = sort { $a->[1] <=> $b->[1] } pair(%{flatten(\%data)}); print $_->[0], "\n" for @sorted[0..2]; __END__ 1.b 1.a 2.b
You'll have to implement &pair yourself.

ihb

See perltoc if you don't know which perldoc to read!

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2024-04-26 01:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found