sorting ascending descending?
On Fri, 12 Jan 2001, Torsten Hothorn wrote:
HI! By xx[order(xx)] I can sort the array ascendin. How to sort them descending. eg.:
a<-c(2,3,110,23,4) a[order(a)]
[1] 2 3 4 23 110 but i wont. [1] 110 23 4 3 2
rev(a[order(a)]
Or a[rev(order(a))], which is useful if you want to sort arrays not vectors (just add a comma or two).
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._