Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister

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 surveying the Monastery: (4)
As of 2016-02-07 04:04 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (245 votes), past polls