title: Sort a Dictionary in Swift
body: <p>I know that this topic has been already discussed but I can't solve looking other answers, so sorry in advance for my ripetion!</p>
  
  <p>I need to sort this Dictionary by keys</p>
  
  <pre><code>codeValueDict = ["us": "$", "it": "€", "fr": "€"]
  </code></pre>
  
  <p>so I need a dictionary like this</p>
  
  <pre><code>sortedDict = ["fr": "€", "it": "€", "us": "$"]
  </code></pre>
  
  <p>but I can't do that.</p>
  
  <p>I tried this  </p>
  
  <pre><code>let sortedKeysAndValues = sorted(dictionary) { $0.0 &lt; $1.0 }
  </code></pre>
  
  <p>but after I need to create two arrays from this dictionary (keys and values) and, using that solution </p>
  
  <pre><code>codesArray = sortedKeysAndValues.keys.array
  </code></pre>
  
  <p>give me the error <em>'[(String, String)]' does not have a member named 'keys'</em> because that solution doesn't return exactly a dictionary.</p>
  
  <p>So i tried another solution:</p>
  
  <pre><code>    let prova = codiceNomeDict as NSDictionary
      for (k,v) in (Array(codiceNomeDict).sorted {$0.1 &lt; $1.1}) {
          let value = "[\"\(k)\": \"\(v)\"]"
          println(value)
      }
  </code></pre>
  
  <p>Which works good but then I don't know how create a new dictionary of <em>value</em>s.</p>
  
  <p>What's the best solution? How to make it works?</p>