MATLAB: I AM TRYING TO SORT A MATRIX IN A PARTICULAR ORDER

MATLABsorting

I want to rearrange a matrix in matlab in descending order according to the sum of its columns, but I want the final matrix to not contain the sum but the original elements in the descending order according to the sum calculated earlier.
eg :-
Matrix =
-0.1563 0.3954 0.5763 -0.5416
0.4987 -0.6326 0.6469 0.0382
-0.6848 -0.0949 0.4510 0.6181
0.5079 0.6591 0.2146 0.5685
as you can see the sum of the third column is the highest so i want it to come in the first position in the new matrix an the last is the next highest so it should come in second and so on, thanks.

Best Answer

A = rand(15,10) ; % MAtrix for demo
[val,idx] = sort(sum(A,2)) ; % Get sum and arrange in descending order
iwant = A(idx,:) % arrange the matrix