Created
June 28, 2014 10:02
-
-
Save taktamur/ae39cbcbbdabe41d897f to your computer and use it in GitHub Desktop.
Swift Dictionary sort array
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // https://developer.apple.com/library/prerelease/ios/documentation/swift/conceptual/swift_programming_language/Closures.html | |
| let data:Dictionary = [30:"value1", 20:"2", 10:"3"] | |
| println("patter 1") | |
| for key in sort(Array(data.keys), { (a:Int,b:Int) -> Bool in return a > b }) { | |
| println( data[key] ) | |
| } | |
| println("patter 2") | |
| for key in sort(Array(data.keys), { return $0 > $1 }) { | |
| println( data[key] ) | |
| } | |
| println("patter 3") | |
| for key in sort(Array(data.keys), {$0 > $1 }) { | |
| println( data[key] ) | |
| } | |
| println("patter 4") | |
| for key in sort(Array(data.keys), >) { | |
| println( data[key] ) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment