#Helping to filter array in angular with another array

5 messages · Page 1 of 1 (latest)

bold marlin
#

Hello, along with saying hello, I wanted to see how I can filter an array depending on another array:

array1: [
{id: 3, name: peter},
{id: 1, name: jonh},
{id: 2, name: jupiter}
]

array2: [
{id: 1, name: jonh},
{id: 2, name: jupiter},
{id: 3, name: peter}
]

The code im looking for is:
array 2 always should keep the order of they "id" of array 1. So array 2 should be 3 | 1 | 2, what code should add after the declaration of array 2, to sort in that way?

crisp sorrel
#

What's the expectation about the filter? Array 2 includes only items from array 1?

bold marlin
#

Hi Gerome

#

i did this: marOrder(array2, array1, id)

#

and now its working!!