How to sort one column of a matrix

31 views (last 30 days)
I have a matrix that has 500 rows and 5 columns. I want to sort the matrix based on the 3 rd column. I mean rearrange the matrix based on the 3rd column descending.

Accepted Answer

Stephan
Stephan on 13 Aug 2019
Edited: Stephan on 13 Aug 2019
B = sortrows(A,-3)
  3 Comments
Stephan
Stephan on 13 Aug 2019
Edited: Stephan on 13 Aug 2019
note that i used
sortrows
instead of
sort

Sign in to comment.

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!