Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: sorting keys in hash

by dbuckhal (Chaplain)
on May 26, 2014 at 00:17 UTC ( [id://1087381]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
     Jul11 = 1107
     Jun11 = 1106
     Aug13 = 1308
     May14 = 1405
     etc...
    
  2. or download this
    sub sortKeys {
        my ( $l_mo, $l_yr ) = $a =~ /(\D+)(\d+)/;
    ...
        my $right = $r_yr . $months->{$r_mo};
        return ( $left cmp $right );
    }
    
  3. or download this
    sub sortKeys {
        ( my $left  = $a ) =~ s/(\D+)(\d+)/$2 . $months->{$1}/e;
        ( my $right = $b ) =~ s/(\D+)(\d+)/$2 . $months->{$1}/e;
        return ( $left cmp $right );
    }
    
  4. or download this
    #!/usr/bin/perl 
    
    ...
    Key - May14  and b value - 2
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-19 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found