I have some JSON data that I get from a server. In my JavaScript, I want to do some sorting on it. I think the sort() function will do what I want.
However, it seems
You should be able to convert a JavaScript object into an array like so...
var obj = { '1': 'a', '2': 'b', '3': 'c' }; var arr = []; for (var key in obj) { if (obj.hasOwnProperty(key)) { arr.push(obj[key]); } } console.log(arr); // ["a", "b", "c"]
See it on jsFiddle.