in reply to sort hash by value

Sorting the full list of items to get just the top n is not the most efficient way, there are better algorithms. See Selection_algorithm.

You can also use Sort::Key::Top instead of implementing those algorithms yourself ;-)