Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

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 wandering the Monastery: (3)
As of 2015-11-27 05:23 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (718 votes), past polls