in reply to sort my arrayref

You can do this by using the special $a and $b variables with sort. Like so:
@a = ( ["oops", 0], [ "happy", 2 ], [ "word", 4 ] ); foreach $ar(sort {$a->[0] cmp $b->[0]} @a) { print "$ar->[0] is $ar->[1]\n"; }
The way I remember how to do this is to think that sort can use an optional code block with $a and $b... $a and $b are automagically populated the same way that (in this case) $ar is populated, and they're populated with the same kind of data that $ar is, again, in this case a reference to an anonymous array. By de-referencing $a and $b to the parts you want to sort by you get the kind of sort you want. If you wanted to sort by the second element in each anonymous array, use $a->[1] cmp $b->[1] instead.

Gary Blackburn
Trained Killer