如何在MATLAB中进行嵌套排序? [英] How would I do a nested sort in MATLAB?
本文介绍了如何在MATLAB中进行嵌套排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在寻找在MATLAB中使用矩阵进行嵌套排序的方法.说我的矩阵看起来像这样:
I am looking to do a nested sort with a matrix in MATLAB. Say my matrix looks like this:
[b a;
b c;
a c;
a a]
我想先按第一列进行排序并保持该排序,然后再按第二列进行排序.结果将是:
I would like to first sort by the first column and maintain that sort, then sort by the second column. The result would be:
[a a;
a c;
b a;
b c]
怎么办?
推荐答案
更详细地说,是sortrows(A,[1 2]),其中A是您的矩阵.
To be more detailed, sortrows(A,[1 2]), where A is your matrix.
这篇关于如何在MATLAB中进行嵌套排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文