Trying to sort NSMutableDictionary in Swift 3, the code from Swift 2 no longer works for me (various errors).
I am trying to use the following code to sort my dictionary by its values: float:
var sortedDict = unsortedDict.allValues.sorted({ $0 < $1 }).flatMap({ floatedlotterydictionary[$0] })
Essentially, I need this unsorted dictionary ...
{ a = "1.7"; b = "0.08"; c = "1.4"; }
... to include this sorted dictionary ...
{ b = "0.08"; c = "1.4"; a = "1.7"; }
But using this line of code above returns the error "The argument type anyobject does not match the NSCopying type" for part $0 < $1 . So how can I sort a dictionary by its values ββin Swift 3?
(Note: This line of code is partially derived from this answer .)
I am using Swift 3 in Xcode 8 beta 1 .
source share