a=[1 2 3;2 1 5;1 3 5];
b=sortrows(a,1);
c=sortrows(b,2);
也可按逆序排序,如:
d=sortrows(a, [-1, -2])
先按第一列的值对行进行降序排序,再对第一列中包含相同值的行按照第二列的值进行降序排序
This example specifies two columns to sort by: columns 1 and 2. This tells sortrows to sort by column 1 first, and then for any rows with equal values in column 1, to sort by column 7.