Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Bert Jung <bjung59@gmail.com> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: Sorting matrix on a column |
Date | Fri, 21 Jan 2011 11:09:00 -0500 |
Dear Statalisters, I need to sort a matrix according to a specific column. For example: mat a = ( ( 4 \ 2 \ 3 \ 1 ) , ( 90 \ 95 \ 92 \ 96 ) ) mat list a a[4,2] c1 c2 r1 4 90 r2 2 95 r3 3 92 r4 1 96 I would like to sort this matrix on the first column in decreasing order to get: 1 96 2 95 3 92 4 90 I realize that Mata's -sort(,)- may do this easily but don't have much experience with Mata and prefer a "regular" Stata solution. Thanks for any pointers, Bert * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/