http://www.perlmonks.org?node_id=736523


in reply to something weird in this hash sorting

you must sort the keys numerical. try:
for my $ctrl_2 ( sort { $b <=> $a } keys (%final) ){ ... }
and read perldoc -f sort for more information.
Boris