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?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…