I want to sort the following information by the string value (not the key number). I am able to convert it to a dictionary and order by value ("AAA" and "CCC") in the code below... now the only question is, how do I convert the dictionary to the same format below in the parseJSON function? I cannot change the format of the JSON so that's out of the question. Any other ways are appreciated. I cannot move it to an array or anything. As stated in my question, the JSON format exists as is and I cannot change it.
var studentCollection.Groups = $.parseJSON("{\"1000\":\"CCC\", \"1001\":\"AAA\"}");
//Sorting the studentCollection.Groups dictionary.
//Even though the groups come back as valid/sorted JSON
//upon parsing the JSON, the groups sorting gets lost
var items = Object.keys(studentCollection.Groups).map(function (key) {
return [key, studentCollection.Groups[key]];
});
items.sort(function (first, second) {
if (first[1] < second[1])
return -1;
if (first[1] > second[1])
return 1;
return 0;
});