iOS Swift how to order Dictionnary by keys
<p>I'm trying to order a Dictionary of [Double : Article] by key (The Double). </p>

<p>I've tried everything, now I have the following code :</p>

<pre><code>    // getting an array of sorted keys
    let articlesKeys = articles.keys.sort{$0 &gt; $1}

    var sortedArticles = [Double:Article]()

    // trying to fill the new dictionary in a descending keys order
    for key in articlesKeys
    {
        sortedArticles[key] = articles[key]
    }

    // replacing the old dictionary (articles)
    // with the new and ordered one (sortedArticles)
    articles.removeAll()
    articles = sortedArticles
</code></pre>

<p>The problem is that "articleKeys" is ordered</p>

<p>print(articleKeys) ===> [220, 218, 110]</p>

<p>but when i print out "sortedArticles" or the new "articles" :</p>

<p>print(sortedArticles) ===> [110 : X], [220 : Y], [218 : Z]</p>

<p>The dictionary has not been ordered :(</p>