Answers for "sort by attribute in reactjs"

0

sort by attribute in reactjs

const list = [
  { qty: 10, size: 'XXL' },
  { qty: 2, size: 'XL' },
  { qty: 8, size: 'M' }
]

list.sort((a, b) => (a.qty - b.qty) ? 1 : -1)

console.log(list)
Posted by: Guest on January-18-2021

Code answers related to "sort by attribute in reactjs"

Code answers related to "Javascript"

Browse Popular Code Answers by Language