Cody

# Problem 44888. Given a matrix A (size m x n) create a matrix B which consists of matrix A sorted in descending order by columns and then by rows.

Solution 1808698

Submitted on 7 May 2019 by assaf ronen
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
x = [2 6 -3 7 12 0 -12 5 1]; y_correct = [12 7 1 6 2 0 5 -3 -12]; assert(isequal(doubleSort(x),y_correct))

A = 7 12 1 2 6 0 -12 5 -3 A = 12 7 1 6 2 0 5 -3 -12 y = 12 7 1 6 2 0 5 -3 -12

2   Pass
x = randi(10,5,8); assert(isequal(size(doubleSort(x)),size(x)))

A = 7 8 6 10 10 8 8 10 7 8 5 7 8 8 8 10 6 6 4 1 8 5 7 7 6 2 4 1 6 3 5 6 3 1 3 1 4 3 2 2 A = 10 10 10 8 8 8 7 6 10 8 8 8 8 7 7 5 8 7 7 6 6 5 4 1 6 6 6 5 4 3 2 1 4 3 3 3 2 2 1 1 y = 10 10 10 8 8 8 7 6 10 8 8 8 8 7 7 5 8 7 7 6 6 5 4 1 6 6 6 5 4 3 2 1 4 3 3 3 2 2 1 1

3   Pass
x=magic(6); y_correct = ... [ 36 35 34 27 26 25 33 32 31 24 23 22 30 29 28 21 20 19 18 17 16 9 8 7 15 14 13 6 5 4 12 11 10 3 2 1]; assert(isequal(doubleSort(x),y_correct))

A = 35 36 34 26 27 25 31 32 33 22 23 24 30 28 29 21 19 20 8 9 7 17 18 16 4 5 6 13 14 15 3 1 2 12 10 11 A = 36 35 34 27 26 25 33 32 31 24 23 22 30 29 28 21 20 19 18 17 16 9 8 7 15 14 13 6 5 4 12 11 10 3 2 1 y = 36 35 34 27 26 25 33 32 31 24 23 22 30 29 28 21 20 19 18 17 16 9 8 7 15 14 13 6 5 4 12 11 10 3 2 1