| Programming |     ![]()  | 
Sorting the Data in Each Row
Sort each row of A in descending order. Note that issorted tests for an ascending sequence. You can flip the vector to test for a sorted descending sequence:
r = sort(A, 2, 'descend') r = 9.5013 7.6210 6.1543 4.0571 0.5789 9.3547 7.9194 4.5647 3.5287 2.3114 9.2181 9.1690 8.1317 6.0684 0.1850 issorted(fliplr(r(1, :))) ans = 1
When you specify a second output, sort returns the indices of the original matrix A positioned in the order they appear in the output matrix. In the following example, the second row of index contains the sequence 4 3 2 5 1, which means that the sorted elements in output matrix r were taken from A(2,4), A(2,3), A(2,2), A(2,5), and A(2,1):
   | Sorting the Data in Each Column | Sorting Row Vectors | ![]()  | 
© 1994-2005 The MathWorks, Inc.