So i have two array and i want to sort the array with, Also i dont want to delete unqiue keys, the solution provided deletes the key and give array of lenght 3.:
const data = [
{
id: '111',
user: '178'
},
{
id: '222',
user: '180'
},
{
id: '333',
user: '186'
},
{
id: '112',
user: '180'
}
]
const someUser = ['180', '186', '178']
And i want output as:
[
{
id: '222',
user: '180'
},
{
id: '112',
user: '180'
},
{
id: '333',
user: '186'
},
{
id: '111',
user: '178'
}
]
If we run a map or forEach loop, i want to get array of object according to the user
field. Like if user 180
has 2 fields in data then i want first array with 2 objects of user containing 180.