Here is an example of an array:
[[ 'Table', 'Column A', 'Column B', 'Column C'],
[ 'Row 1', 10, 5, 7 ],
[ 'Row 2', 20, 15, 50 ],
[ 'Row 3', 8, 13, 3 ]]
I am looking to rearrange the columns based on values in 'Row 1' to prioritize the most important column. The desired result is:
[[ 'Table', 'Column A', 'Column C', 'Column B'],
[ 'Row 1', 10, 7, 5 ],
[ 'Row 2', 20, 50, 12 ],
[ 'Row 3', 8, 3, 13 ]]
Observe how column positions have changed for C and B.
Any suggestions on how to achieve this using JavaScript?