How to sort an array of objects with jquery or javascript [duplicate]

I have an array of objects:

var array = [(id, name, value),(id, name, value)]; //and so on

How do I get the array to be sorted in ascending order of the atribute name (array[i][1])?

I’ve tried to do this: array[i][1].sort(), but that doesn’t work.

Please help me!

Edit: the array can contain more than two objects! It can contain hundreds.

Edit:
Why is this question marked as a duplicate, when it was asked 2 years before the “duplicated” question?

6 Answers
6

Leave a Comment