Programming Previous page   Next Page

Sorting Row Vectors

The sortrows function keeps the elements of each row in their original order but sorts the entire row vectors according to the order of the elements in the first column:

To run the sort based on a different column, include a second input argument that indicates which column to use. This example sorts the row vectors so that the elements in the third column are in ascending order:

Previous page  Sorting the Data in Each Row Operating on Diagonal Matrices Next page

© 1994-2005 The MathWorks, Inc.