mysql - How sort json array multiple times in swift -


i trying sort array few values, not 1 3 can sort this

mysocialarray.sort({$0["date"] > $1["date"]}) 

this works fine, can find how sort again them sorted on time , sort. should sort 3 times. when add sort not taking date account.

the sorted json output loaded in arrays strings display on viewcontroller

how should solve this?

thanks

given requirements of "this way latest post not yet have been read @ top", looks looking sort multiple criteria. typed in dark may have adjust fit case:

mysocialarray.sort {     // first sort read status. assuming read of type bool     let (read1, read2) = ($0["read"] ? 1 : 0, $1["read"] ? 1 : 0)     if read1 != read2 {         return read1 > read2     }      // short date. assume date of type nsdate     let (date1, date2) = ($0["date"], $1["date"])     if date1.timeintervalsince1970 != date2.timeintervalsince1970 {         return date1 > date2     }      // , lastly sort time     return $0["time"] > $1["time"] } 

Comments