Given
4 2 5 2 7 9 10 1 2
Sort each column on its own, so that the result is
2 1 2 4 2 5 10 7 9
In Matlab, the sort command is used. But in the Mathematica, the Sort command is the same the Matlab’s sortrows() command, hence it can’t be used as is. Map is used with Sort to accomplish this.
Mathematica mat={{4,2,5}, {2,7,9}, {10,1,2}}; Map[Sort[#]&,Transpose[mat]]; mat=Transpose[%]
|
{{2, 1, 2}, {4, 2, 5}, {10,7, 9}} |