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


in reply to Re^2: Sorting Dates
in thread Sorting Dates

>Does that sort the hash too

You cannot sort a hash : a hash is by construction with no particular order. What you can do is sort the keys of a hash and print the corresponding values.

When you do  foreach (keys %hash) you get the keys in an order that is undefined although always the same. But it will change if you add or remove keys, therefore if you need a specific order you should do  foreach ( sort { my sort function} keys %hash )