Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: how to sort

by glenn (Scribe)
on Sep 13, 2013 at 14:01 UTC ( [id://1053943]=note: print w/replies, xml ) Need Help??


in reply to how to sort

Have you considered using AoA? http://www.sitepoint.com/forums/showthread.php?659680-Perl-Sort-Array-of-Arrays&p=4508119&viewfull=1#post4508119
my @AoA = ( ['a', '2003-11-09', 'b'], ['c', '2003-11-01', 'd'], ['e', '2002-11-01', 'f'], ['g', '2003-10-01', 'h'], ['g', '2002-10-01', 'h'], ); my @new_arr = sort {$a->[1] cmp $b->[1]} @AoA; for (@new_arr) { say "@$_"; } --output:-- g 2002-10-01 h e 2002-11-01 f g 2003-10-01 h c 2003-11-01 d a 2003-11-09 b

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (4)
As of 2024-03-19 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found