Then I'd guess Kayaman has the right idea - your keys are strings and not integers. You could provide a comparator for the map, one that parses the strings and compares the int values. It would of course be better to use integer keys though. Btw, you really should use typed maps, i.e. TreeMap<Integer, Whatever>.