in reply to sort while push in hash

If you want to insert an element into an array at a certain position, then check out the splice function in your docs.

shift,unshift, push and pop add or remove elements from the beginning and end of an array, respectively.

Hanlon's Razor - "Never attribute to malice that which can be adequately explained by stupidity"