I have a data array like this:
dataArray = [
0: {"Item1" : Val1, "Item2" : Val2, "Item3" : Val3 ... "ItemN" : ValN}
1: {"Item1" : Val1, "Item2" : Val2, "Item3" : Val3 ... "ItemN" : ValN}
.
.
N: {"Item1" : Val1, "Item2" : Val2, "Item3" : Val3 ... "ItemN" : ValN}
]
I have another array which contains a set of arbitrary, variable elements in a desired order:
selArray = ["Item2", "Item9", "Item7"]
The desired output:
outArray = [
0: {"Item2" : Val2, "Item9" : Val9, "Item7" : Val7}
1: {"Item2" : Val2, "Item9" : Val9, "Item7" : Val7}
.
.
N: {"Item2" : Val2, "Item9" : Val9, "Item7" : Val7}
]
I want to select and reorder the elements in dataArray based on the elements in selArray. The contents of both dataArray and selAarray are going to change multiple times in the application, so the selecting on position in the array, or deleting items in the array won't work.
Would appreciate any ideas about how to do this. TIA