I'm trying to write a code to take a matrix as input and reorganize its rows by sum from lowest to highest.
so if the matrix is
2 2 2 (sum 6)
1 1 3 (sum 5)
2 5 6 (sum 13)
then I want it to reorder as
1 1 3 (sum 5)
2 2 2 (sum 6)
2 5 6 (sum 13)
So far what I did is sum each row and insert it in a one dimension array and sort it from lowest to highest ,but I'm having trouble reordering the original matrix. Any ideas?
Thanks in advance.