Answers for "sort array by time javascript"

14

sort by date js

array.sort((a,b) =>  new Date(b.date) - new Date(a.date));
Posted by: Guest on June-18-2021
28

sort js array by date

// Price Low To High
array?.sort((a, b) => (a.price > b.price ? 1 : -1))
// Price High To Low
array?.sort((a, b) => (a.price > b.price ? -1 : 1))
// Name A to Z
array?.sort((a, b) => (a.name > b.name ? 1 : 1))
// Name Z to A
array?.sort((a, b) => (a.name > b.name ? -1 : 1))
// Sort by date
array.sort((a,b) =>  new Date(b.date) - new Date(a.date));
Posted by: Guest on November-03-2021
17

javascript order array by date

const sortedActivities = activities.sort((a, b) => b.date - a.date)
Posted by: Guest on April-16-2020

Code answers related to "sort array by time javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language