Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: storing values of hash of hashes in an array based on numerical order of second key

by BillKSmith (Monsignor)
on Aug 17, 2020 at 23:04 UTC ( [id://11120856]=note: print w/replies, xml ) Need Help??


in reply to storing values of hash of hashes in an array based on numerical order of second key

This can be solved with a special case of the Schwartzian Transform. How do I sort an array by (anything)
use strict; use warnings; my %pos2base2bin = ( '315' => { '8' => 0 }, '329' => { '6' => 0 }, '352' => { '5' => 0 }, '390' => { '1' => 0 }, '280' => { '7' => 1 }, '360' => { '9' => 0 }, '349' => { '4' => 0 }, '305' => { '10' => 0 }, '380' => { '3' => 1 }, '251' => { '2' => 0 } ); my @file1 = map {$_->[1]} sort {$a->[0] <=> $b->[0]} map {[each %$_]} values %pos2base2bin; $"= "\t"; print "file1 @file1\n";
Bill
  • Comment on Re: storing values of hash of hashes in an array based on numerical order of second key
  • Download Code

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found