How can I sort a 2-D array in MATLAB with respect to one column?

前端 未结 2 1715
温柔的废话
温柔的废话 2020-11-27 05:33

I would like to sort a matrix according to a particular column. There is a sort function, but it sorts all columns independently.

For example, if my mat

2条回答
  •  遥遥无期
    2020-11-27 06:11

    I think the sortrows function is what you're looking for.

    >> sortrows(data,1)
    
    ans =
    
        -1     4
         1     3
         5     7
    

提交回复
热议问题