Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: sorting array of arrays

by hippo (Chancellor)
on Jan 18, 2020 at 17:27 UTC ( #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
Node Status?
node history
Node Type: note [id://11111574]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2020-03-30 20:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    To "Disagree to disagree" means to:









    Results (176 votes). Check out past polls.

    Notices?