Array1 contains a list of strings. Array_set contains a list of keyword lists.
array1 = ["1","1","3","2","4"]
array_set = [
[key1: "string", key2: "another string", key3: 0, id: 1],
[key1: "string", key2: "another string", key3: 0, id: 2],
[key1: "string", key2: "another string", key3: 0, id: 3],
[key1: "string", key2: "another string", key3: 0, id: 4],
[key1: "string", key2: "another string", key3: 0, id: 5],
[key1: "string", key2: "another string", key3: 0, id: 6],
[key1: "string", key2: "another string", key3: 0, id: 7]
]
I’m trying to get the following output
by matching the string values of array1 with the id in array_set. Duplicates are allowed in array1 and output
should match the original order of array1
.
Example of what I’m trying to achieve. Looking for some help on this. Thank you!!
output = [
[key1: "string", key2: "another string", key3: 0, id: 1],
[key1: "string", key2: "another string", key3: 0, id: 1],
[key1: "string", key2: "another string", key3: 0, id: 3],
[key1: "string", key2: "another string", key3: 0, id: 2],
[key1: "string", key2: "another string", key3: 0, id: 4]
]