Before rendering in the browser, I need to organize my JSON data object. Here is the format of my JSON:
$scope.cityData= [
{
id: '520',
city:'col01'
},
{
id: '410',
city:'col02'
},
{
id: '412',
city:'col03'
}]
I attempted to sort it using code, but there seems to be an issue as the console log did not show it as sorted.
$scope.cityData.sort(function (a, b) { return a.id - b.id });
console.log($scope.cityData);
$scope.newCitySort = $scope.cityData;
I also want to assign this sorted data to a new scope variable. How can I achieve this?