A couple of things. First, you really ought to use an array
here, instead of simulating an array with a hash. Second, I
doubt you want to sort lexicographically. Third, it's showing
four twice because you never delete the highest number when
re-assigning the numbers.
I'm not going to waste time in showing you corrected code.
Your design is absurd. Use an array.