I need to re-order multidimensional arrays of with n, where n can be up to 50 or more
from here I can reorder if I list All
the column indices, which again could be up to 50 or more
function rearrange(rows, pos) {
return rows.map(function(cols) {
return pos.map(function(i) {
return cols[i];
});
});
}
I want to only list the indices of the columns I want to reorder and move these columns to the beginning of the array leaving all the other columns in the order they are left in
Bob|Carol|Ted|Alice
a |b |c |d
1 |2 |3 |4
A |B |C |D
If the list of indices is list=[3] so I get
Alice|Bob|Carol|Ted
d |a |b |c
4 |1 |2 |3
D |A |B |C
list = [2,3]
Ted|Alice|Bob|Carol
c |d |a |b
3 |4 |1 |2
C |D |A |B
Thank you