I am creating a JSON object in which i am adding a key and a value which is an array. The value for both key and value comes from a TreeSet which has data in sorted form. Ho
Below are what the doc says from http://www.json.org/java/index.html.
"A JSONObject is an unordered collection of name/value pairs."
"A JSONArray is an ordered sequence of values. "
In order to get an sorted Json Object, you can use Gson which is already provided a good answer by @user748316.