Skip to content
Advertisement

Sorting the array of objects by key name using date-fns library in javascript

Here array containing the name along with the updatedTimeStamp propery. I want to sort the array based on the updatedTimeStamp property.

So I am hereby using date-fns library and I want to use this library only , I can do without this library but that’s my requirement to use this library.

I can able to do sort based on the updatedTimeStamp but its not return the name how can I return the name property along with updatedTimeStamp.

JavaScript

Advertisement

Answer

I would do it like this instead. You can pas your own function which returns the comparsefunc instead

JavaScript
Advertisement