in reply to sort hash by value
You can also use Sort::Key::Top instead of implementing those algorithms yourself ;-)