6
rated 0 times
[
8]
[
2]
/ answers: 1 / hits: 47525
/ 11 Years ago, tue, october 8, 2013, 12:00:00
I have some JSON that is formatted like:
places =[
{
city:Los Angeles,
country:USA,
},
{
city:Boston,
country:USA,
},
{
city:Chicago,
country:USA,
},
]
et cetera...
I am trying to sort this alphabetically BY CITY and am having trouble doing so. I believe the root of my issue seems to be determining the order of the characters (versus numbers). I've tried a simple:
places.sort(function(a,b) {
return(a.city) - (b.customInfo.city);
});
yet, this subtraction doesnt know what to do. Can someone help me out?
More From » json