Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: sorting array of array references with multiple dereferenced array elements

by LanX (Saint)
on Sep 23, 2014 at 13:16 UTC ( [id://1101634]=note: print w/replies, xml ) Need Help??


in reply to Re: sorting array of array references with multiple dereferenced array elements
in thread sorting array of array references with multiple dereferenced array elements

This

> for my $i (0 .. $#a) {

looks wrong: $a is an array ref there is no @a involved.

IIRC $#$a should do.

Note This code is untested. ;)

Cheers Rolf

(addicted to the Perl Programming Language and ☆☆☆☆ :)

update

now tested! :)

DB<109> $a=[1..10] # arrref => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] DB<110> $#$a => 9 DB<111> $a=[map [0..$_],0..3 ] # AoA => [[0], [0, 1], [0, 1, 2], [0, 1, 2, 3]] DB<112> $#{$a->[2]} => 2 DB<113> @b=(1..5) # @array => (1, 2, 3, 4, 5) DB<114> $#b => 4

though I couldn't find a good documentation yet! :(

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-03-29 01:42 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found