I want to sort table including its legend for graph
I have table similar to
M1 M2 M3
1 5 2
3 1 4
4 2 -10
5 7 11
6 -2 1
I want the labellings M1, M2 and M3 to move with the first row of numbers while sorting by row basis.
M1 M3 M2
1 2 5
...........
...........
OK The code is below
(* Initial matrix *)
h = {{M1, M2, M3}, {1, 5, 2}, {3, 1, 4}, {4, 2, -10}, {7, 5, 11}, {6, -2, 1}}
then sorting by basis h1 = Sort /@ h gives
M1, M2, M3
1, 2, 5
1, 3, 4
-10, 2, 4
5, 7, 11
-2, 1, 6
I want M1, M2 and M3 to be together with the fist row of numerical values since they are labellings attached to the first numerical values of each column
AS
M1 M3 M2
1 2 5
..... ....
In that way it will be easy to put the legend in graphs