I am stumped by this and obviously missing something basic. It seems perl sort is not working on particular set of value. Here is part of test code:
use str
By default, sort will sort lexically. So 23 and 24 come before 7 for the same reason that bc and bd come before g in the dictionary.
sort
sort {$a <=> $b} @p will yield a numeric sort.
sort {$a <=> $b} @p
http://perldoc.perl.org/functions/sort.html for more info.