sort cell array in descending order based on 2nd column

12 次查看(过去 30 天)
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