Here is SpringMVC Controller code snippet:
@RequestMapping(value = \"/getCityList\", method = RequestMethod.POST)
public @ResponseBody LinkedHashMap
If you wanted to send sorted data then pass List of Your object or City as List which have sorted data.
I have also face same problem when I have used HashMap in my application, it doesn't guarantee that it will receive in same order in which we add them. We have to access it via it's key.
so it's better to use List instead of LinkedHashMap.
Most implementations of JSON make no effort to preserve the order of an object's name/value pairs, since it is (by definition) not significant.