我在 Javascript 中有这个对象:
[
{
"id": "60001",
"name": "NORTH COLORADO MEDICAL CENTER",
"friendly_name": "Kidney Failure - w/o CC MCC",
"address": "1801 16TH STREET",
"state": "CO",
"zip": "80631",
"service_count": "14",
"charges": "18,381",
"payments": "4,339",
"distance": "49.920"
},
{
"id": "60031",
"name": "CENTURA HEALTH-PENROSE ST FRANCIS HEALTH SERVICES",
"friendly_name": "Kidney Failure - w/o CC MCC",
"address": "2222 N NEVADA AVE",
"state": "CO",
"zip": "80907",
"service_count": "21",
"charges": "18,512",
"payments": "3,801",
"distance": "60.961"
}
]
默认情况下,对象按“id”排序。我想按现在的样子获取该对象,并按字段“名称”按升序排序,而不是“id”。检查下面以查看我希望如何显示结果。
[
{
"id": "60031",
"name": "CENTURA HEALTH-PENROSE ST FRANCIS HEALTH SERVICES",
"friendly_name": "Kidney Failure - w/o CC MCC",
"address": "2222 N NEVADA AVE",
"state": "CO",
"zip": "80907",
"service_count": "21",
"charges": "18,512",
"payments": "3,801",
"distance": "60.961"
},
{
"id": "60001",
"name": "NORTH COLORADO MEDICAL CENTER",
"friendly_name": "Kidney Failure - w/o CC MCC",
"address": "1801 16TH STREET",
"state": "CO",
"zip": "80631",
"service_count": "14",
"charges": "18,381",
"payments": "4,339",
"distance": "49.920"
}
]