I have an array called myArray in which dictionaries are added I want that dictionary to be sorted by time which is a key in dictionary. And that time is in String. The date format of time is "yyyy/MM/dd HH:mm:ss"
I tried with below code solution but gives a warning of "Cast from 'String?' to unrelated type 'Date' always fails".
let sortedArray = self.myArray.sorted{ ($0["Time"] as? Date)! > ($1["Time"] as? Date)! }
print(sortedArray)
If anyone can help me out, Thank You.