sort
Sort an array.
(y, ind)=sort(a)
Inputs
a Any matrix or a one-dimensional array of strings.
Outputs
y The sorted array.
ind The array of indices that may be used to construct y from a .


Description
If a is a vector, the output is the sorted vector, with ind bing an array of indices of a such that y=a(ind) .

If a is a matrix, each column of the y is the vector of sorted elements if the corresponding elements of a , with the sorting indices being the elements of the corresponding elements of ind , such that y[:,j]=a[:,ind[:,j]] .

If a is a matrix, the sorted matrix y can be obtained from a and ind by using the call shuffle(a,ind) .
Example
>>a=[ [2 1 3 4]' fix(rand(4,4)*100)]
>>b=[ [2 1 3 4]' fix(rand(4,4)*100)]
>>a
          2         72          8         79         13
          1         21         40         96         55
          3         76         34         23         91
          4         82          3         70         89

>>b
          2         17         28         75         55
          1         79         70          7          7
          3         92         87         91         17
          4         93         98         24         51

>>[sa,ind]=sort(a)
>>sa  // all columns of sa are in ascending order.
          1         21          3         23         13
          2         72          8         70         55
          3         76         34         79         89
          4         82         40         96         91
>>shuffle(a,ind) // ind and 'shuffle' can be used to sort a
          1         21          3         23         13
          2         72          8         70         55
          3         76         34         79         89
          4         82         40         96         91
>>// If the rows of the the columns of a and b are related in some fashion
>>// shuffle(b, ind) can be used to get the same ordering of the rows
>>// of the columns of b as sort(a) yields for the columns of a.
>>shuffle(b,ind)  
          1         79         98         91         55
          2         17         28         24          7
          3         92         87         75         51
          4         93         70          7         17