Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

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?

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (13)
As of 2015-07-30 19:05 GMT
Find Nodes?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...

    Results (273 votes), past polls