SwiftyJson Results in UITableView wrong order
<p>I'm working on a simple JSON reader app using Alamofire and SwiftyJson. Getting the file and parsing them into the UITableView is working fine except for the fact that it shows them in the wrong results. </p>

<p>How do I get them to show in the order as specified by the JSON file?</p>

<p>Here is the output:
<a href="https://i.stack.imgur.com/9tdyu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9tdyu.png" alt="enter image description here"></a></p>

<p>As you can see, Category3 shows first, then Category1.</p>

<p>I would like them in the order of the Json:</p>

<pre><code>{"Posts": [
{
    "Category1": [
        "Post1",
        "Post2",
        "Post3",
        "Post4",
        "Post5",
        "Post6",
        "Post7"
    ],
    "Category2": [
        "Post1",
        "Post2",
        "Post3",
        "Post4",
        "Post5",
        "Post6",
        "Post7",
        "Post8"
    ],
    "Category3": [
        "Post1",
        "Post2"
    ]
}
]}
</code></pre>

<p>View Controller code:</p>

<pre><code>func getSectionsFromData(completion: ([Sections]) -&gt; ()) {
    var sectionsArray = [Sections]()

    Alamofire.request(.GET, url).validate().responseJSON { response in
        switch response.result {
        case .Success:
            if let value = response.result.value {
                let json = JSON(value)

                for (_, subJson) in json["Posts"] {
                    for (title, data) in subJson {
                        let optionalCastedObjects = data.arrayObject as? [String]
                        let unwrappedObjects = optionalCastedObjects ?? []
                        let section = Sections(title: title, objects: unwrappedObjects)

                        sectionsArray.append(section)
                    }
                }

                completion(sectionsArray)
            }
        case .Failure(let error):
            print(error)
        }
    }
}
</code></pre>

<p>UITableView Reload:</p>

<pre><code>SectionsData().getSectionsFromData { [weak self](sections: [Sections]) -&gt; () in
        self?.sections = sections
        self?.tableView.reloadData()
        self!.activityIndicatorView.stopAnimating()
    }
</code></pre>