Ant design Table components sort sorter

{
    title: "",
    className: "listTable listTime",
    dataIndex: "eventtime",
    key: "eventtime",
    width: "12%",
    **sorter: (a, b) => Date.parse(a.eventtime.replace("-","/").replace("-","/")) - Date.parse(b.eventtime.replace("-","/").replace("-","/")),**
    render: (text, record, index) => {
         return <label>{text}</label>;
       }
  },
  

A sorting error occurred after sorting the query results in ascending order. The functions of the two time sorting buttons behind the alarm time are not unified, the upward buttons can only be arranged in descending order, and the downward buttons can. What"s wrong with the ordering of my sorter ? Beg urgently! Thank you!

Mar.10,2021

use timestamps as much as possible. The
comparison can be subtracted directly using a timestamp. You can also use some methods of momentjs , such as isAfter isBefore , and so on.


Thank you, boss, the problem has been solved image.png

Menu