Swift (Xcode 7.3.1) and sorting using values in a Dictionary -


i have array of dictionaries appears below , want sort , store such objects sorted based on 'value' of 'like' key ? how do in swift ? thanks.

{     dislike = 0;     = 5;     username = t; } {     dislike = 0;     = 0;     username = s; } {     dislike = 0;     = 10;     username = n; } 

i suppose that's array of dictionaries?

if case, can sort them follows

//anyobject in case number nsnumber var array: [[string:anyobject?]] = yourarray   array.sort{ $0["like"]!! > $1["like"]!! } 

basically mutates array , sort based on "like" key.


Comments

Popular posts from this blog

mysql - Dreamhost PyCharm Django Python 3 Launching a Site -

java - Sending SMS with SMSLib and Web Services -

java - How to resolve The method toString() in the type Object is not applicable for the arguments (InputStream) -