in reply to sort hash values which is an array

If you write %hash = { ... } the outcome will not be what you expect. use strict: use warnings will guard you against such mistakes.

Use (...) instead of {...}.