Here is an array of objects that I need to rearrange:
var items = [
{ key: 'address', value: '1234 Boxwood Lane' },
{ key: 'nameAndTitle', value: 'Jane Doe, Manager' },
{ key: 'contactEmail', value: '<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9bf5f0f7f1fcf2f6ebf7dffaf0fcf4f1b3fef2f0">[email protected]</a>' },
{ key: 'contactPhone', value: '9876543210' },
{ key: 'localPhone', value: '9876543210' },
{ key: 'status', value: 'pending' },
]
I have another array called order
with the desired order for these objects:
var order = [
'nameAndTitle',
'contactPhone',
'contactEmail',
'address',
]
I need to arrange the items
array according to the order specified in the order
array. Any ideas on how to achieve this?