I'm to trying sort an array of array by date in Swift, but I'm getting this three errors:
- Cannot infer contextual base in reference to member 'orderedAscending'
- Value of type 'Any' has no member 'compare'
- Cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members
That is the array declaration:
let array = [[5.5, 1, 2020-11-05 23:00:00 +0000], [8.0, 2, 2020-11-10 23:00:00 +0000], [5.5, 1, 2020-10-27 23:00:00 +0000]]
and that is the code that I've written to sort the array:
let sortedArray = array.sorted(by: { (($0[2]).compare($1[2]))! == .orderedAscending })
array = sortedArray
How can I solve? Thanks in advance