sorting a matrix in descending order
Show older comments
I have a matrix
group =
0 0 0 1
0 1 0 0
0 0 1 0
0 1 0 0
0 0 0 1
0 0 1 0
0 0 1 0
0 1 0 0
0 0 0 1
0 1 0 0
1 0 0 0
0 1 0 0
if I want to sort in ascending order I can use
sortrows(group)
ans =
0 0 0 1
0 0 0 1
0 0 0 1
0 0 1 0
0 0 1 0
0 0 1 0
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
0 1 0 0
1 0 0 0
but I want to sort in descending order. What to do?
Accepted Answer
More Answers (1)
bym
on 21 Apr 2012
sort(group,1,'descend')
3 Comments
the cyclist
on 21 Apr 2012
I don't think this method retains the integrity of the rows, but rather sorts the columns independently.
Asawari
on 18 Oct 2013
Can I use this descend command to arrange any array or matrix in descending order?I am using mesh command to create a curve.Mesh command creates origin of the curve between X-Y plane by default.I want to change the origin from X-Y plane to Y-Z plane and X axis I want to arrange in descending order,I am stuck here,can anyone help?
the cyclist
on 18 Oct 2013
I suggest you make a new question, with more detail and maybe a small example. Questions buried in comments don't get seen as much.
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!