I'm trying to create a dictionary from sorted array of times (which are string). Here is the code:
var usernameCommentsSorted: [String : [String : String]] = [:]
print("not sorted: \(Array(usernameComments.keys))")
let sortedKeys = Array(usernameComments.keys).sorted()
print("sorted: \(sortedKeys)")
for time in sortedKeys {
print("time in for loop -- \(time) --")
usernameCommentsSorted[time] = ["F" : "F"]
}
print("sorted final dictionary: \(usernameCommentsSorted)")
and here's the output:
So my question is, why is the dictionary not receiving the times as the for in loop goes? Maybe I'm missing some behaviour of dictionaries.
Thank you in advance.