in reply to Creating a two dimensional array and sorting by index

See perldata, perllol and perlfunc (for map and sort).

my @AoA = ( [ 'foo' , 1 ], [ 'bar' , 5 ], [ 'buz' , 3 ], ); print "@$_\n" for sort { $a->[1] <=> $b->[1] } @AoA; @AoA = (); #free structure
--
http://fruiture.de

Replies are listed 'Best First'.
Re: Re: Creating a two dimensional array and sorting by index
by kirk123 (Beadle) on Dec 09, 2002 at 20:10 UTC
    Can I do it like this, since I don't know what the string is going to be just there order. my @AoA = ( $string1 , 1 , $string2 , 5 , $string3 , 3 , ); print "@$_\n" for sort { $a->1 <=> $b->1 } @AoA; @AoA = (); #free structure