Roberta wrote:
> I have a matrix like this:
>
> a=
> 3 6 8 2
> 2 3 5 1
>
> I woluld like :
> b=
> 8 6 3 2
> 5 3 2 1
>
> I have to sort the first row of a matrix in a descending
> order in MATA.
> Is possible?
>
Try the following:
. mata
------------- mata (type end to exit) -------------
: x = (3, 6, 8, 2) \ (2, 3, 5, 1)
: x
1 2 3 4
+-----------------+
1 | 3 6 8 2 |
2 | 2 3 5 1 |
+-----------------+
: sort(x',-1)'
1 2 3 4
+-----------------+
1 | 8 6 3 2 |
2 | 5 3 2 1 |
+-----------------+
:
See -help mf_sort- for more information.
- Jesper K. Hansen
*
* For searches and help try:
* http://www.stata.com/support/faqs/res/findit.html
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/