title: Sort Dictionary by values in Swift
body: <p>Is there are analog of - (NSArray *)keysSortedByValueUsingSelector:(SEL)comparator in swift?</p>
  
  <p>How to do this without casting to NSDictionary?</p>
  
  <p>I tried this, but it seems to be not a good solution.</p>
  
  <pre><code>var values = Array(dict.values)
  values.sort({
      $0 &gt; $1
      })
  
  for number in values {
      for (key, value) in dict {
          if value == number {
              println(key + " : \(value)");
              dict.removeValueForKey(key);
              break
          }
      }
  }
  </code></pre>
  
  <p>Example:</p>
  
  <pre><code>var dict = ["cola" : 10, "fanta" : 12, "sprite" : 8]
  dict.sortedKeysByValues(&gt;) // fanta (12), cola(10), sprite(8)
  </code></pre>