Sort array by dates in React JS

前端 未结 3 1739
遥遥无期
遥遥无期 2020-12-31 23:24

I have an array of objects as follows :

let cars = [
    {\"id\":20,\"mileage\":41300,\"make\":\"Golf\", initialRegistration:\"09/02/2010\"}, 
    {\"id\":21         


        
3条回答
  •  醉话见心
    2021-01-01 00:07

    Your sorting way is proper, just change the date format in cars array, make it MM:DD:YYYY, or YYYY:MM:DD it will work, because these are the formats that Date parse accept.

提交回复
热议问题