我有这样的jsonarray
事情:
var jsonarr= [{"displayName":"Rachita Jain","phoneNumbers":[{"value":"(787) 989-6756"},{"value":"
(897) 867-4666"}]},{"displayName":"Akanksha Mittal","phoneNumbers":[{"value":"(678) 456-4677"}]}]
我想使用基于displayName
.
我有这样的jsonarray
事情:
var jsonarr= [{"displayName":"Rachita Jain","phoneNumbers":[{"value":"(787) 989-6756"},{"value":"
(897) 867-4666"}]},{"displayName":"Akanksha Mittal","phoneNumbers":[{"value":"(678) 456-4677"}]}]
我想使用基于displayName
.
使用排序函数数组:
var jsonarr = [{
"displayName": "Rachita Jain",
"phoneNumbers": [{
"value": "(787) 989-6756"
}, {
"value": "(897) 867-4666"
}]
}, {
"displayName": "Akanksha Mittal",
"phoneNumbers": [{
"value": "(678) 456-4677"
}]
}];
jsonarr.sort(function (item1, item2) { return (item1.displayName > item2.displayName) ? 1 : -1 });
console.log(jsonarr);