sort cell array in descending order based on 2nd column

조회 수: 12 (최근 30일)
jahanzaib ahmad
jahanzaib ahmad 2019년 3월 26일
댓글: Adam Danz 2019년 3월 26일
i have cell array and want to sort it based on 2nd column .
i have tried this
[~,idx] = sort([AA{:,2}]);
idx([1:2:end,2:2:end]) = idx;
B = AA(idx,:);
but 2nd column in not in descending order .

채택된 답변

Adam Danz
Adam Danz 2019년 3월 26일
편집: Adam Danz 2019년 3월 26일
The [65 x 2] cell array in your mat file is named "A1".
[~, idx] = sort([A1{:,2}], 'descend');
A1_descendingOrder = A1(idx,:)

추가 답변 (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