Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Sorting two dimensional arrays

by toonski (Beadle)
on Aug 16, 2003 at 22:34 UTC ( [id://284370]=perlquestion: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
      @myarray = (
                   ['one','two','three','four'],
                   ['first','second','third','fourth'],
                   ['jim','bob','bill','sally'],
                 );
    
  2. or download this
      @myarray = sort {$a->[$n] cmp $b->[$n]} @myarray;
    
  3. or download this
      my @arraylist = sort {$myarray[$a] cmp $myarray[$b]} 0..$#myarray;
      for $listitem (@arraylist) {
        print $myarray[$listitem];
      }
    
  4. or download this
      for $listitem (@arraylist) {
        print $myarray[$listitem][0] . "<br>";
        print $myarray[$listitem][1] . "<br>";
        print $myarray[$listitem][2] . "<br>";
      }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://284370]
Approved by graff
Front-paged by hsmyers
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 02:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found