in reply to sorting and array by [2]

I just want to comment on the line
$a->[2] cmp $b->[2] || $a->[2] <=> $b->[2]
If this was meant to be the sort subroutine, it has some problems (other than the aready mention ones). The or (||) is operating on the results of two comparison operators that return -1, 0 , 1. This will not a result that sort will be able to use. This will be interpreted as "Compare column 2 as text and if the elements are equal compare them as numbers". so it is still wrong. cmp is use for string and <=> is used for numbers. By the time you are executing the sort, you should know what the type is.

Update: Based on this node : Q&A Node on multicolumn sorting and some other research I realized my orignal statment was not fully correct. The node does not mention that this works because the or operater (||) short circuits if not false. The whole expression returns the -1 or 1 value for the first sub expression that has non false value or return 0 if they are all equal. I guess a real monk should add this to the node.