I shall like to sort out an array in order chronological. I know not at all how to take myself there ... Here is the array:
[["FM", "TEL", "ID", "2017-06-17 18:16:29 +0000", "TYPE", "inbox"], ["FM", "TEL", "ID", "2017-06-17 18:17:24 +0000", "TYPE", "no", "send"], ["Jm", "TEL", "ID", "2017-06-17 19:25:27 +0000", "TYPE", "no", "send"]]
I tried with that but that did not work ....
str.sort({$0[3].date > $1[3].date})
I shall like the most recent date at the beginning, the output should be like this:
[["Jm", "TEL", "ID", "2017-06-17 19:25:27 +0000", "TYPE", "no", "send"], ["FM", "TEL", "ID", "2017-06-17 18:17:24 +0000", "TYPE", "no", "send"], ["FM", "TEL", "ID", "2017-06-17 18:16:29 +0000", "TYPE", "inbox"], ["FM", "TEL", "ID", "2017-06-17 18:17:24 +0000", "TYPE", "no", "send"]]
str.sort {$0[3].date > $1[3].date}stackoverflow.com/questions/26719744/…$0[3].dateWhat's that call.date?$0[3]is a String. You need to convert it into(NS)Datewith(NS)DateFormatter. Also, I strongly suggest to use a proper class/struct rather than a array to keep your data.