I'm trying to sort this array on vCount (descending) but I can't figure out how to do so. I've searched stack overflow but I can't find anything similar to my issue.
This is what I came up with this far, I guess this doesn't work because vCount is deeper in the array but how do I get deeper in the array within the sort function?
var nar = trck_urls.sort(function(a, b){ // trck_urls is the array
return b['vCount'] - a['vCount'];
});
This is the array I'm trying to sort. (console.log output)
[ '/home': [ pageTitle: 't1',
Visitors: [ 'oPc-Gr6SYxN1AMyw8Pst' ],
vCount: 1 ],
'/dash': [ pageTitle: 't2',
Visitors: [ 'jepoSdBR9_ur3XSu8Psu', 'WIO4fEt1Ue8yHCly8Psv' ],
vCount: 2 ] ]
console.log
, you've abused JavaScript arrays. If it's your script, then you've got a syntax error. – Bergi May 25 '14 at 20:42