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 ( #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? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2022-01-24 20:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (65 votes). Check out past polls.

    Notices?