abhishek jagwani
abhishek jagwani

Reputation: 13

Sort whole array in MATLAB (rows and columns simultaneously)

I have a unsorted array

A =

10   -12     4     8
 6    -9     8     0
 2     3    11    -2
 1     1     9     3

I want to get it sorted fully and have the following result

A =

-12   -9    -2    0
 1     1     2    3
 3     4     6    8
 8     9    10   11

how can i do that?

Please help.

Thanks in advance :)

Upvotes: 0

Views: 40

Answers (1)

Lincoln Cheng
Lincoln Cheng

Reputation: 2303

Do this:

A = sort(reshape(A,[1 16]));

Upvotes: 3

Related Questions