Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Sorting two dimensional arrays

by benn (Priest)
on Aug 16, 2003 at 23:00 UTC ( #284375=note: print w/ replies, xml ) Need Help??


in reply to Sorting two dimensional arrays

I *think* you're simply after....

my $n = 2; # sort on 3rd item my @sorted = sort {$array[$a][$n] cmp $array[$b][$n]} 0..$#array; foreach (@sorted) { print $array[$_][0],"<br>"; print $array[$_][1],"<br>"; # etc. }
Cheers, Ben.


Comment on Re: Sorting two dimensional arrays
Download Code
Re: (2) Sorting two dimensional arrays
by toonski (Beadle) on Aug 16, 2003 at 23:25 UTC
    I'm slapping my forehead, benn. Thank you! :)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (3)
As of 2014-09-21 12:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (168 votes), past polls