Сортировка по дате JS
array.sort((a,b) => new Date(b.date) - new Date(a.date));
Jealous Jellyfish
array.sort((a,b) => new Date(b.date) - new Date(a.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));
const sortedActivities = activities.sort((a, b) => b.date - a.date)
array.sort((a,b) => new Date(b.date) - new Date(a.date));
arr = arr.sort(function (a, b) {
var dateA = new Date(a.date_prop).getTime();
var dateB = new Date(b.date_prop).getTime();
return dateA < dateB ? 1 : -1;
});
array.sort(function(a,b){return a.getTime() - b.getTime()});