Horje
javascript sort array by A-Z in js Code Example
javascript sort array by A-Z in js
// 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));




Javascript

Related
javascript check if undefined or null Code Example javascript check if undefined or null Code Example
page reload timeout Code Example page reload timeout Code Example
jquery when you typing in input Code Example jquery when you typing in input Code Example
parseint array javascript Code Example parseint array javascript Code Example
jquery doc ready Code Example jquery doc ready Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8