Sorting elements in a matrix via first column characterization

I'd like to know if there's a way to sort rows of a matrix by the entries in the first column.
For example, if I have a matrix
A = [9 4 5; 3 3 1; 5 8 4;]
I want to do something like "B = sort(A)" and have MATLAB return:
B = [3 3 1; 5 8 4; 9 4 5;]
Where all rows are sorted based on the first entry. Thanks.

回答(1 个)

类别

帮助中心File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

提问:

2015-6-15

评论:

2015-6-15

Community Treasure Hunt

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

Start Hunting!

Translated by