How do I sort an array in descending order without using the sort function?
显示 更早的评论
采纳的回答
更多回答(2 个)
Walter Roberson
2015-11-5
flipud(unique(A(:)))
Here are a few ways to sort an array of unique values without using sort:
sortrows(A(:),-1)
A(end:-1:1) = unique(A);
fliplr(union(A,A(1)))
fliplr(setdiff(A,NaN))
类别
在 帮助中心 和 File Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!