How to order matrix rows?

1 view (last 30 days)
Mr M.
Mr M. on 17 Apr 2015
Answered: Star Strider on 17 Apr 2015
I have a matrix something like this
1 1 ...
2 1 ...
3 1 ...
1 2 ...
2 2 ...
3 2 ...
1 3 ...
2 3 ...
3 3 ...
I would like to arrange rows according to the first column, but I would like to hold the order for equal values, so I would like the following output
1 1 ...
1 2 ...
1 3 ...
2 1 ...
2 2 ...
2 3 ...
3 1 ...
3 2 ...
3 3 ...

Accepted Answer

Star Strider
Star Strider on 17 Apr 2015
Use the sortrows function, specifying column #1.

More Answers (0)

Categories

Find more on Creating and Concatenating 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!