Say I have matrix
how to sort on row by row basis to get:
mat
Sort /@ mat
Sort on row by row basis:
mat = {{1, 3, 2, 4}, {4, 3, 2, 1}, {3, 2, 4, 1}, {1, 2, 4, 3}};
Sort on column by column basis:
mat2 = {{4, 3, 1, 4}, {2, 4, 3, 2}, {1, 1, 2, 3}, {3, 2, 4, 1}};
Transpose[Sort /@ Transpose[mat2]]
Sign up using Google
Sign up using Facebook
Sign up using Stack Exchange
By posting your answer, you agree to the privacy policy and terms of service.
tagged
asked
6 months ago
viewed
94 times
active
matbe your matrix, thenSort /@ mat. – VLC Nov 15 '12 at 13:05