I have JSON that is formatted like this:
places =[ { "city":"Los Angeles", "country":"USA", }, { "city":"Boston", "country":"USA", }, { "city":"Chicago", "country":"USA", }, ]
et cetera ...
I am trying to sort this alphabetically BY BY CITY and I am having problems with this. I believe that the root of my problem seems to determine the character order (compared to numbers). I tried just:
places.sort(function(a,b) { return(a.city) - (b.customInfo.city); });
this subtraction does not know what to do. Can someone help me?
source share