Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Sorting arrays based on a single element

by kilinrax (Deacon)
on May 09, 2003 at 18:51 UTC ( [id://256974]=note: print w/replies, xml ) Need Help??


in reply to Sorting arrays based on a single element

I'm assuming you have something like this:
# id day number my @array = ( [ 1, 25, 6156 ], [ 2, 13, 5324 ], [ 3, 32, 13617 ] );
In which case, you want to sort it thusly:
my @sorted_array = sort { $a->[1] <=> $b->[1] } @array;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (7)
As of 2024-03-28 12:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found