I have an array with the following structure:
[[],[{"id":1,"meaning":1,"word":"b"},{"id":2,"meaning":1,"word":"a"}],[{"id":3,"meaning":2,"word":"f"},{"id":4,"meaning":2,"word":"c"}],[{"id":5,"meaning":3,"word":"d"}]]
array[0]
needs to be empty, because I need that index for a special usage later on.
array[1]
for example contains all objects with meaning:1
, array[2]
all those with meaning:2
.
What I want to do now is to sort this array by the first object in the 2D-Array(so to say by the first column).
Thus the output should be like:
[[],[{"id":1,"meaning":1,"word":"b"},{"id":2,"meaning":1,"word":"a"}], [{"id":5,"meaning":3,"word":"d"}], [{"id":3,"meaning":2,"word":"f"},{"id":4,"meaning":2,"word":"c"}]]
I would appreciate all types of answers.
EDIT: The sort criterion is an ascending alphabetic order
.sort()
method, but it didn't do what I expected. I take use of AngularJS and JQuery in my application.