Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Sorting Multilevel Hashes

by hdb (Parson)
on Apr 25, 2014 at 06:29 UTC ( #1083733=note: print w/ replies, xml ) Need Help??


in reply to Sorting Multilevel Hashes

If you only want to print the sorted rows into another file, then IMHO it is easier to read the file into an array of arrays and sort them then.

use strict; use warnings; my $header = <DATA>; my @rows = map { join "\t", @$_ } sort { $a->[1] cmp $b->[1] || $a->[2] cmp $b->[2] || $a->[3] cmp $b->[3] || $a->[4] <=> $b->[4] } map {[ split /\s+/ ]} <DATA>; print $header; print "$_\n" for @rows; __DATA__ pin Name related_pin time_type rise_fall delay DQ5_RX_CLK M2CLKP c_rise rise_transition 0.014446 DQ2_RX_CLK M2CLKP c_rise rise_transition 0.014464 DQ0_RX_CLK M2CLKP c_rise rise_transition 0.014452 DQ3_RX_CLK M2CLKP c_rise rise_transition 0.014452 DQ7_RX_CLK M2CLKP c_rise rise_transition 0.014430 DQ4_RX_CLK M2CLKP c_rise rise_transition 0.014446 DQ8_RX_CLK INT_CLK c_fall fall_transition 0.199360 DQ6_RX_CLK INT_CLK c_fall fall_transition 0.199322 DQ1_RX_CLK INT_CLK c_fall fall_transition 0.199500 DQ5_RX_CLK INT_CLK c_fall fall_transition 0.199248 DQ2_RX_CLK INT_CLK c_fall fall_transition 0.199368


Comment on Re: Sorting Multilevel Hashes
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2014-09-03 04:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls