vendredi 14 août 2020

Sort JavaScript Object by key and value

I need to sort JavaScript Object in Ember.js by key and value.

input:

{
  'Super': 'Man',
  'New': 'Test',
  'New': 'Apple'
}

output:

{
  'New': 'Apple',
  'New': 'Test',
  'Super': 'Man'
}

There is a function called sortBy in Ember.js which can be used to sort key, but I am not sure how to sort value when keeping sorting key alphabetically.




Aucun commentaire:

Enregistrer un commentaire