1
I own an object that contains several arrays within it. And these arrays contain other objects that contain a field lpec_sequence
that I would like that under every hierarchy, it was ordered by that field. And I would also like to scroll through each existing sub_menu within the objects and sort them too.
{
"layout": {
"menu_events": [
{
"lpec_id": 90,
"lpec_sequence": 1,
"sub_menu": false
},
{
"lpec_id": 125,
"lpec_sequence": 2,
"sub_menu": false
},
{
"lpec_id": 124,
"lpec_sequence": 3,
"sub_menu": true,
"sub_menu_items": [
{
"lpec_id": 96,
"lpec_sequence": 5,
"sub_menu": false
},
{
"lpec_id": 97,
"lpec_sequence": 6,
"sub_menu": false
},
{
"lpec_id": 98,
"lpec_sequence": 7,
"sub_menu": false
},
{
"lpec_id": 99,
"lpec_sequence": 8,
"sub_menu": true,
"sub_menu_items": [
{
"lpec_id": 100,
"lpec_sequence": 1,
"sub_menu": false
},
{
"lpec_id": 101,
"lpec_sequence": 2,
"sub_menu": false
},
{
"lpec_id": 102,
"lpec_sequence": 3,
"sub_menu": false
},
{
"lpec_id": 103,
"lpec_sequence": 4,
"sub_menu": false
},
{
"lpec_id": 104,
"lpec_sequence": 5,
"sub_menu": false
},
{
"lpec_id": 105,
"lpec_sequence": 6,
"sub_menu": false
},
{
"lpec_id": 106,
"lpec_sequence": 7,
"sub_menu": false
}
]
},
{
"lpec_id": 118,
"lpec_sequence": 10,
"sub_menu": true,
"sub_menu_items": [
{
"lpec_id": 121,
"lpec_sequence": 3,
"sub_menu": false
},
{
"lpec_id": 122,
"lpec_sequence": 4,
"sub_menu": false
},
{
"lpec_id": 119,
"lpec_sequence": 1,
"sub_menu": false
},
{
"lpec_id": 120,
"lpec_sequence": 2,
"sub_menu": false
}
]
},
{
"lpec_id": 92,
"lpec_sequence": 1,
"sub_menu": false
},
{
"lpec_id": 93,
"lpec_sequence": 2,
"sub_menu": false
},
{
"lpec_id": 94,
"lpec_sequence": 3,
"sub_menu": false
},
{
"lpec_id": 95,
"lpec_sequence": 4,
"sub_menu": false
},
{
"lpec_id": 107,
"lpec_sequence": 9,
"sub_menu": true,
"sub_menu_items": [
{
"lpec_id": 109,
"lpec_sequence": 2,
"sub_menu": false
},
{
"lpec_id": 110,
"lpec_sequence": 3,
"sub_menu": false
},
{
"lpec_id": 111,
"lpec_sequence": 4,
"sub_menu": false
},
{
"lpec_id": 112,
"lpec_sequence": 5,
"sub_menu": false
},
{
"lpec_id": 114,
"lpec_sequence": 7,
"sub_menu": false
},
{
"lpec_id": 113,
"lpec_sequence": 6,
"sub_menu": false
},
{
"lpec_id": 115,
"lpec_sequence": 8,
"sub_menu": false
},
{
"lpec_id": 116,
"lpec_sequence": 9,
"sub_menu": false
},
{
"lpec_id": 117,
"lpec_sequence": 10,
"sub_menu": false
},
{
"lpec_id": 108,
"lpec_sequence": 1,
"sub_menu": false
}
]
}
]
},
{
"lpec_id": 123,
"lpec_sequence": 2,
"sub_menu": true,
"sub_menu_items": [
{
"lpec_id": 91,
"lpec_sequence": 1,
"sub_menu": false
}
]
}
]
}
}
Hello, thanks for the reply. But I checked that the object with the id
lpec_id: 107
and thelpec_id: 118
is not ordered. I wonder what happens ?– Jonathan
@Jonathan I just noticed that there are 3 levels of depth, some
sub_menu_items
have othersub_menu_items
in. That’s just the way or not?– Sergio
Yes yes, in this case there are 3 levels, but there can be 2 or even more than 3
– Jonathan
@Jonathan ok, and the sublevels are always called
sub_menu_items
or there are other names?– Sergio
Always the same.
– Jonathan
@Jonathan take a look now.
– Sergio
Perfect. Thank you very much
– Jonathan