Tree Top View - Wrong answer

My logic is fine, but my hashmap is not printing values in ascending order according to keys instead it is displaying according to value.

output should be
4 2 1 3

and my output is : 1 2 3 4