Why is the code not giving correct output?

I referred to the hint and still this does not give me a sorted array

you simply need to store the count of 0’s, 1’s and 2’s and then print the zeros, ones and twos according to the count
code