Sort in ascending order for first column then descending order for the second column.

12 ビュー (過去 30 日間)
Hi,
A=[1 1 1;
3 2 1;
1 3 1]
is there a way in matlab to sort rows of a matrix based on ascending order for the first column and then descending order for the second column, so the final matrix will look like this:
A=[1 3 1;
1 1 1;
3 2 1]

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2014 年 3 月 29 日
A=[1 1 1; 3 2 1; 1 3 1]
B=sortrows(A,[1 -2])

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by