MATLAB: Sorting a matrix based on L2 norm of each row

sorting

Hello all
Please how to code; descendent sorting a matrix C(9000×9000) based on L2 norm of each row then reconstruct a new ranked matrix.
Thanks in advance

Best Answer

Try this
M = rand(9000); % random matrix for example
[~, idx] = sort(vecnorm(M, 2, 2), 'descend');
M_sorted = M(idx, :);
Related Question