Sorting a Matrix by columns
16 views (last 30 days)
Show older comments
NotRiyad NotHosein
on 20 Mar 2021
Commented: NotRiyad NotHosein
on 21 Mar 2021
I have a 12 x 12 matrix and I have used the command 'sortrows' to sort the matrix in ascending order of rows. How can I do the same but sorting by columns (i.e. ascending order of columns) instead of rows?
0 Comments
Accepted Answer
Cris LaPierre
on 21 Mar 2021
I would suggest transposing your matrix, sortrows, then transpose the result.
A=rand(5)
B=sortrows(A')'
More Answers (0)
See Also
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!