Sort the array of Dates in the Model iOS Swift
Sort the date array using for loop is not a great way.So we can use the below method to sort the array of dates
let DateSorted = NSMutableArray(array:datearray.sortedArray(using: [NSSortDescriptor(key: "date", ascending: true)]))
The array model contains the key attribute named as the date.So we used the key value as date and sort using ascending order.
Comments
Post a Comment