I have an array that is loaded from MYSQL database using PHP and converting to JSON, the data get loaded into the table, but now I want to sort this data, how can I do this? I would like to sort them by latest time = in my object array.
JSON Result got with NSURLSession:
(
{
id = 8;
time = "2015-07-24 17:12:00";
title = "World is full of good people!";
},
{
id = 10;
time = "2015-07-24 18:44:30";
title = "One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin. He lay on his armour-like back, and if he lifted his head.";
}
)
I read some questions/answers on stackoverflow.com and people are saying I should use sorted on my array, but I think that method is gone in swift 2.
This is what I get once i try it arr.sorted
'NSArray' does not have a member named 'sorted'
I find an apple sorting document, but couldn't find any good answer to describe on how to use it.
sortisn't gone, it's just not a global function anymore. It's now a function on array.