I have two Arrays:
const dropdownOptions = [
{ text: 'NuxtJS', sortOrder: 1 },
{ text: 'VueJS', sortOrder: 2 },
]
And:
const sidebar = [
{
text: 'VueJS',
collapsible: true,
items: [ [Object], [Object], [Object], [Object], [Object] ]
},
{
text: 'NuxtJS',
collapsible: true,
items: [ [Object], [Object], [Object], [Object] ]
}
]
I'd like to sort the sidebar variable based on the sortOrder value within the dropdownOptions array. So, for this example, the expected output would be:
const sortedSidebar = [
{
text: 'NuxtJS',
collapsible: true,
items: [ [Object], [Object], [Object], [Object] ]
},
{
text: 'VueJS',
collapsible: true,
items: [ [Object], [Object], [Object], [Object], [Object] ]
}
]