Hi, I have a 5×2 matrix and I would like to sort the first column and keep the rows together after the sorting is done. For example, I have an array given by
UP = zeros(5,2)ai = [13,11,15,26,20]for i = 1:5 UP(i,1) = ai; UP(i,2) = i;end
After I sort the first column of the array, I would like to keep the second column assigned with the value of the first column. I would like an output that looks like the following
11,213,115,320,526,4
Best Answer