Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js sort object properties alphabetically

const data = {
  States: ['NSW', 'VIC'],
  Countries: ['GBR', 'AUS'],
  Capitals: ['SYD', 'MEL']
}

const sortedObject = Object.fromEntries(Object.entries(data).sort())
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #sort #object #properties #alphabetically
ADD COMMENT
Topic
Name
2+8 =