我使用 .push() 添加了一个 JavaScript 对象,但问题是当我将数据推送到对象时,该对象不再按时间值排序。如何创建相同的对象,但始终按 time_going_hour 排序,然后按 time_going_minutes 排序?
"days": {
"1": {
"places": [{
"url": "/attraction/mauna-kea-summit/19",
"img_src": "http://trekeffect.images.user_images.s3.amazonaws.com/4_36.jpg",
"title": "Mauna Kea Summit",
"time_going_hour": 1,
"time_going_minutes": 55,
"duration": "3600",
"id": 19,
"type": "attraction",
"city_id": 6
}, {
"url": "/attraction/the-st.-benedict-painted-church/21",
"img_src": "http://trekeffect.images.user_images.s3.amazonaws.com/4_42.jpg",
"title": "The St. Benedict Painted Church",
"time_going_hour": 8,
"time_going_minutes": 35,
"duration": "2600",
"id": 21,
"type": "attraction",
"city_id": 6
}, {
"url": "/attraction/mauna-kea-summit/19",
"img_src": "http://trekeffect.images.user_images.s3.amazonaws.com/4_36.jpg",
"title": "Mauna Kea Summit",
"time_going_hour": 3,
"time_going_minutes": 51,
"duration": "3600",
"id": 19,
"type": "attraction",
"city_id": 6
}]
}