也许我需要将数组转换为实际日期才能使其正常工作?如果使用时刻表演会有问题,因为我也需要对数组进行排序。
>>> float(response.xpath('count(//p)').get())
1.0
>>> float(response.xpath('count(//div)').get())
0.0
const arr = [{
"created_at": "2017-07-19 10:37:20"
}, {
"created_at": "2017-07-19 10:38:02"
}, {
"created_at": "2017-07-19 10:38:06"
}, {
"created_at": "2017-07-19 10:38:35"
}, {
"created_at": "2017-07-19 10:39:21"
}, {
"created_at": "2017-07-19 10:39:49"
}, {
"created_at": "2017-07-19 10:42:06"
}, {
"created_at": "2017-07-19 10:42:20"
}, {
"created_at": "2017-07-19 10:45:01"
}, {
"created_at": "2017-07-19 10:45:09"
}]
console.log(_.sortBy(arr, 'created_at'))
答案 0 :(得分:2)
Lodash sortBy正在按预期使用您的数据,但您已经发布了排序数据,这就是您收到相同结果的原因。