Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re: sorting array of arrays

by hippo (Bishop)
on Jan 18, 2020 at 17:27 UTC ( [id://11111574]=note: print w/replies, xml ) Need Help??


in reply to sorting array of arrays

Your sorting code treats each element of @ar as an array when it is instead an array ref. Using warnings would have alerted you to that.

@ar = ([1,12],[8,3],[4,57],[22,5]); @sort = sort{$a->[1]<=>$b->[1]}@ar; foreach (@sort){ print "@$_\n"; }

Replies are listed 'Best First'.
Re^2: sorting array of arrays
by Anonymous Monk on Jan 18, 2020 at 17:43 UTC

    Tx.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-20 15:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found