in reply to modify the order a list with the help of a hash table

I'd like to add to other monks' comments by adding that

use strict; use warnings;

would have caught your mistake with sort.