I am getting a response from the remote server from which i had created a jsonObject. now when I'm iterating the response for the key "instances" which contains a value of dictionary the response is shuffled. the key element of the dictionary which is a date is not coming in sequence while printing.
here is the json response:
{
    "data": [
        {
            "id": "apkqY19RthbN",
            "theater_id": "clzEVgztkcWB",
            "theater_audi_id": "7LFeNCaCrm8h",
            "movie_lang_id": "0VTEIjLeDxK1",
            "booking_start_date": null,
            "instances": {
                "2018-04-20": [
                    {
                        "id": "WRK81ahlWcZZ",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "cDqZjYKHP2xt",
                        "show_time": "20:00:00"
                    }
                ],
                "2018-04-21": [
                    {
                        "id": "DcVQhohv9C3W",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "bZOUk3AT6TMM",
                        "show_time": "20:00:00"
                    }
                ],
                "2018-04-22": [
                    {
                        "id": "5YJAydTua6b2",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "qKGXgWvV0r38",
                        "show_time": "20:00:00"
                    }
                ],
                "2018-04-23": [
                    {
                        "id": "AGciEXINppMe",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "YbKFBJV67hFW",
                        "show_time": "20:00:00"
                    }
                ],
                "2018-04-24": [
                    {
                        "id": "5vj9t1i5B4J3",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "um7UeNPJuAcv",
                        "show_time": "20:00:00"
                    }
                ],
                "2018-04-25": [
                    {
                        "id": "AbS69J4SM4gG",
                        "show_time": "17:00:00"
                    },
                    {
                        "id": "gKax9RXMLozN",
                        "show_time": "20:00:00"
                    }
                ]
            }
        }
    ]
}
here is my code that i had tried:
 _ = URLSession.shared.dataTask(with: request) { (Data, response, error) in
            if Data != nil{
                do{
                    let access = try JSONSerialization.jsonObject(with: Data!, options: []) as! [String: Any]
                   // print(access)
                    if let data = access["data"] as? [[String:Any]]{
                        if let id = data[0]["id"] as? String{
                            global.showID = id
                          //  print(data)
                        }
                        var j = 0
                        for l in 0..<data.count{
                        if let instances = data[l]["instances"] as? [String:Any] {
                            print(instances)
                            for (key,obj) in instances{
                                //for (key,obj) in (instances as [String:Any]){
                                //print(key)
                                var showDetails: [ShowData] = [ShowData]()
                                if let timeObj = obj as? [[String: Any]]{
                                    var k = 0
                                    for i in 0..<timeObj.count{
                                        let showTime = timeObj[i]["show_time"]
                                        //print(showTime!)
                                        let showID = timeObj[i]["id"]
                                        //print(showID!)
                                        let a = ShowData.init(showId: showID as! String, showtime: showTime as! String)
                                        showDetails.insert(a, at: k)
                                        //print(showDetails)
                                        k += 1
                                    }
                                }
                                let a = Shows(date: key , instance: showDetails)
                                self.showsDate?.insert(a, at: j)
                                //print(self.showsDate!)
                                j += 1
                            }
                            Completion(self.showsDate!)
                        }
                        }
                    }
                }catch let e{
                    print(e)
                }
            }
            }.resume()
print(instances) when i am printing this the output is :
["2018-04-25": <__NSArrayI 0x143bd1ac0>(
{
    id = AbS69J4SM4gG;
    "show_time" = "17:00:00";
},
{
    id = gKax9RXMLozN;
    "show_time" = "20:00:00";
}
)
, "2018-04-24": <__NSArrayI 0x143b3aca0>(
{
    id = 5vj9t1i5B4J3;
    "show_time" = "17:00:00";
},
{
    id = um7UeNPJuAcv;
    "show_time" = "20:00:00";
}
)
, "2018-04-23": <__NSArrayI 0x143be0ce0>(
{
    id = AGciEXINppMe;
    "show_time" = "17:00:00";
},
{
    id = YbKFBJV67hFW;
    "show_time" = "20:00:00";
}
)
, "2018-04-21": <__NSArrayI 0x143b349c0>(
{
    id = DcVQhohv9C3W;
    "show_time" = "17:00:00";
},
{
    id = bZOUk3AT6TMM;
    "show_time" = "20:00:00";
}
)
, "2018-04-22": <__NSArrayI 0x143b24290>(
{
    id = 5YJAydTua6b2;
    "show_time" = "17:00:00";
},
{
    id = qKGXgWvV0r38;
    "show_time" = "20:00:00";
}
)
, "2018-04-20": <__NSArrayI 0x143bd5430>(
{
    id = WRK81ahlWcZZ;
    "show_time" = "17:00:00";
},
{
    id = cDqZjYKHP2xt;
    "show_time" = "20:00:00";
}
)
]
the dates are not in sequence like in the response.