In my Swift
project there is an Array
with Dictionaries
. Each Dictionary
contains a String
of date
. How can I get a new Array
with date
from newest to oldest? Thanks!
var array = [["date":"2016-02-12","title":"1"],["date":"2014-05-12","title":"2"],["date":"2016-06-18","title":"3"],["date":"2015-09-17","title":"4"]]
Like this:
let array2 = array.sorted {$0["date"]! < $1["date"]!}
来源:https://stackoverflow.com/questions/41047580/how-to-sort-an-array-with-dictionaries-which-include-date