I've got the following objects using AJAX and stored them in an array:
(我使用AJAX获得了以下对象并将它们存储在数组中:)
var homes = [
{
"h_id": "3",
"city": "Dallas",
"state": "TX",
"zip": "75201",
"price": "162500"
}, {
"h_id": "4",
"city": "Bevery Hills",
"state": "CA",
"zip": "90210",
"price": "319250"
}, {
"h_id": "5",
"city": "New York",
"state": "NY",
"zip": "00010",
"price": "962500"
}
];
How do I create a function to sort the objects by the price
property in ascending or descending order using JavaScript only?
(如何创建仅使用JavaScript 按 price
属性按升序 或 降序对对象进行排序的函数?)
ask by community wiki translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…