Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
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
Replies are listed 'Best First'.
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 chilling in the Monastery: (4)
As of 2015-09-03 03:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred temperature scale is:










    Results (93 votes), past polls