Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

typescript sort array of objects

const list = [
  { color: 'white', size: 'XXL' },
  { color: 'red', size: 'XL' },
  { color: 'black', size: 'M' }
]

list.sort((a, b) => (a.color > b.color) ? 1 : -1)
Source by flaviocopes.com #
 
PREVIOUS NEXT
Tagged: #typescript #sort #array #objects
ADD COMMENT
Topic
Name
4+9 =