How to arrange ascending order only one column of a matrix?

3 views (last 30 days)
Let's say, I have a=[25 10 85 35 71; 1 2 3 4 5] and output shout come b=[10 25 35 71 85; 2 1 4 5 3]

Accepted Answer

Birdman
Birdman on 15 Feb 2018
b=sortrows(a.').'

More Answers (1)

Andrei Bobrov
Andrei Bobrov on 15 Feb 2018
[~,ii] = sort(a(1,:));
out = a(:,ii);

Categories

Find more on Resizing and Reshaping Matrices in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!