I am deserializing a JSON string into a dictionary in C# however I would like to sort the dictionary by a value in order to display it on a table of high scores. Right now the Dictionary returns in fixed order.
var temp = Json.Deserialize(www.text) as Dictionary<string,object>;
if (temp != null)
{
data = (List<object>)temp["_items"];
}
JSON String
"_items":[
{
"_updated":"Thu, 01 Jan 1970 00:00:00 GMT",
"_id":"-",
"Name":"John Doe",
"_links":{
"self":{
"href":"Players/-",
"title":"Player"
}
},
"_created":"Thu, 01 Jan 1970 00:00:00 GMT",
"FacebookId":XXXXX,
"HighScore":8862,
"_etag":"-"
},
{
"_updated":"Thu, 01 Jan 1970 00:00:00 GMT",
"_id":"-",
"Name":"John Smith",
"_links":{
"self":{
"href":"Players/-",
"title":"Player"
}
},
"_created":"Thu, 01 Jan 1970 00:00:00 GMT",
"FacebookId":XXXXXX,
"HighScore":32000,
"_etag":"-"
}
],
Cell Creation
var dict = (Dictionary<string, object>) data[row];
// Set Name
cell.nameText.text = dict["Name"].ToString();
// Set score
cell.score.text = string.Format("{0:n0}", dict["HighScore"]);
// Fb Profile IMG
StartCoroutine(getFBPicture(cell.image, dict["FacebookId"].ToString()));