in reply to sort my arrayref
# say I've got a two dimensional array... @array = ( ["oops", 0], [ "happy", 2 ], [ "word", 4 ] ); # sort on the sub-element of your choice here.... @sorted = sort{$a->[0] cmp $b->[0]}@array; # and I wanna print the contents of it thusly: foreach $ar (@sorted) { print "$ar->[0] is $ar->[1]\n" } # how would I sort the @a based on the $ar->[0]?
|
|---|