sort by attribute in reactjs

Solutions on MaxInterview for sort by attribute in reactjs by the best coders in the world

showing results for - "sort by attribute in reactjs"
Solomon
28 Feb 2016
1const list = [
2  { qty: 10, size: 'XXL' },
3  { qty: 2, size: 'XL' },
4  { qty: 8, size: 'M' }
5]
6
7list.sort((a, b) => (a.qty - b.qty) ? 1 : -1)
8
9console.log(list)