Let say we have our array like this:
let myArray = ["A", "B", "C", "D"]
What if we want to modify the order of elements in myArray based on modifier array so that, if myArray includes any element of modifier then we send that element to the end of the myArray
Like this:
let modifier = ["B"]
myArray = ["A", "C", "D", "B"] // B is sent to the end of myArray
And if we have this:
let modifier = ["A", "C"]
myArray = ["B", "D", "A", "C"] // A and C are sent to the end of the array
I have tried looping and checking each array element against another but it went complicated...
Any help would be greatly appreciated.