I have an ordered array and 4 arrays inside another array. I want to order each array based on the ordered array.
(this is just an example, I need a code that will work with any kind of elements inside the arrays).
let ordered_array = ['a','b','c','d','e','f','g','h','i','j','k','l'];
let array = [['d','c','a'],['i','k','b'],['f','e','h'],['l','g','j']];
//order each array in 'array'
for(let i = 0; i < array.length; i++){
for(let l = 0; l < array[i].length; l++){
document.write(array[i][l]);
}
document.write('</br>');
}
/*
expected output (after order):
acd
bik
efh
gjl
*/