MATLAB: Sorting rows

matrix

I have a matrix ,i have to sort them by "time" variable plz tell how to proceed

Best Answer

time1 = rand(8,1);
yourmatrix = randi(30,8);
solution:
[id,id] = sort(time1);
out = yourmatrix(id,:)
OR:
out1 = sortrows([time1(:), yourmatrix],1);
out = out1(:,2:end)