Cody

# Problem 43609. Sort rows of a matrix

Solution 2071051

Submitted on 27 Dec 2019 by Asif Newaz
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

### Test Suite

Test Status Code Input and Output
1   Pass
A = magic(5); y_correct = [10 12 19 21 3; 11 18 25 2 9; 17 24 1 8 15; 23 5 7 14 16; 4 6 13 20 22]; assert(isequal(your_fcn_name(A),y_correct))

a = 3 9 15 16 22 b = 4 5 1 2 3 c = 5 d = 5

2   Pass
A = 1:5; y_correct = A; assert(isequal(your_fcn_name(A),y_correct))

a = 5 b = 1 c = 1 d = 5

3   Pass
A = [1:4; 9:12; 13:16; 5:8]; y_correct = reshape((1:16),[4,4])'; assert(isequal(your_fcn_name(A),y_correct))

a = 4 8 12 16 b = 1 4 2 3 c = 4 d = 4

4   Pass
A = (1:10)'; y_correct = A; ind = rand(10,1); [~,indA] = sort(ind); A = A(indA); assert(isequal(your_fcn_name(A),y_correct))

a = 1 2 3 4 5 6 7 8 9 10 b = 1 9 6 10 2 8 7 5 3 4 c = 10 d = 1

5   Pass
A = [3:7; 10:-1:6; -4:0; 2:-1:-2]; y_correct = flipud(A); assert(isequal(your_fcn_name(A),y_correct))

a = -2 0 6 7 b = 4 3 2 1 c = 4 d = 5

### Community Treasure Hunt

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

Start Hunting!