sorting matrix in ascending order based on column 1 (and ascending order also for column 2)

4 次查看(过去 30 天)
Hi all, is there a way to sort A in ascending order based on column 1, allowing its other columns to follow with it
A = [1 2 5
1 3 3
2 3 12
1 4 2];
results should be:
B = [1 2 5
1 3 3
1 4 2
2 3 12
];

采纳的回答

the cyclist
the cyclist 2019-9-14
编辑:the cyclist 2019-9-14
Use the sortrows command.
B = sortrows(A,1);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by