in reply to Permanently sort a hash
Thank you everyone for your replies. Appreciate your help a lot, especially herveus's explanation! I will give a try to Tie::Hash::Sorted although I think ikegami's solution is the simplest in my case.