How do I maintain rows when sorting a matrix in MATLAB?

Posted by Jessy on Stack Overflow See other posts from Stack Overflow or by Jessy
Published on 2010-05-27T16:52:33Z Indexed on 2010/05/27 20:51 UTC
Read the original article Hit count: 170

Filed under:
|
|
|

I have a 2-by-3 matrix, and I want to sort it according to the first column. Here's an example:

data   will change to -->  new data
11 33                      10 22
22 44                      11 33 
10 22                      22 44 

I have this code for sorting a matrix A but it doesn't work well:

sort(A,1,'ascend');

© Stack Overflow or respective owner

Related posts about matlab

Related posts about sorting