Skip to content
Advertisement

Ordering an array of objects in javascript [closed]

I have this array:

enter image description here

It has 16 positions and each position is an object with an ID and a content. I have to order this array alphabetically by it’s content. I tried to use sort, but it didn’t work. Can someone help me with this ?

Advertisement

Answer

You should implement the sort method like that:

JavaScript

Or using ES6:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement