javascript - Antd表,如何按日期排序,包括整个时间戳?
问题描述
我有这个项目
const data: Item[] = [
{
key: 1,
name: 'John Brown',
date: moment('10-10-2019').format('L'),
address: 'New York No. 1 Lake Park',
},
{
key: 2,
name: 'Joe Black',
date: moment('11-10-2019').format('L'),
address: 'London No. 1 Lake Park',
},
{
key: 3,
name: 'Jim Green',
date: moment('7-10-2019').format('L'),
address: 'Sidney No. 1 Lake Park',
},
{
key: 4,
name: 'Jim Red',
date: moment('8-10-2019 8:00 PM').format('L'),
// date: moment('8-10-2019 8:00 PM').format('MMMM Do YYYY, h:mm:ss a'),
address: 'London No. 2 Lake Park',
},
];
如果我将该数据用于“日期”,并且我使用以下分拣机,它工作正常
sorter: (a, b) => moment(a.date).unix() - moment(b.date).unix()
但我希望数据更复杂一点,像这样
date: moment('8-10-2019 8:00 PM').format('MMMM Do YYYY, h:mm:ss a')
评估为August 10th 2019, 8:00:00 pm
问题是,我无法使用上述排序器对数据进行排序。我怎么能做到?
解决方案
推荐阅读
- php - php.ini request_order 安全问题
- c# - DefaultCellStyle 不适用
- command - 如何使用命令中心重命名动态输出
- pdf - Google 数据洞察导出为 PDF 和预定的电子邮件
- mongodb - MongoDB:文档何时更新
- verilog - 在 SystemVerilog 中检查 NaN 或 Inf
- mysql - 如何对查询中的计算列进行分组?
- android - 仅对我在 recyclerview 中单击的第一个元素调用 onBindViewHolder
- forms - 由于存储库中的意外实体更改时间,Symfony 表单自定义约束评估失败
- python - 如何分离由 subprocess.call 运行的程序?