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 1883587

Submitted on 25 Jul 2019 by HH
• Size: 7
• This is the leading solution.
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))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In doubleSort (line 2) In ScoringEngineTestPoint1 (line 7) In solutionTest (line 3)]

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

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In doubleSort (line 2) In ScoringEngineTestPoint2 (line 2) In solutionTest (line 5)]

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))

[Warning: Function assert has the same name as a MATLAB builtin. We suggest you rename the function to avoid a potential name conflict.] [> In unix (line 32) In doubleSort (line 2) In ScoringEngineTestPoint3 (line 9) In solutionTest (line 7)]

### Community Treasure Hunt

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

Start Hunting!