[R] Sorting in R

Art Salwin salwin at mitretek.org
Wed Jun 21 16:36:38 CEST 2000

How do you sort one vector using another vector as a sort
key?  Sort of equivalent
to sorting rows of a spreadsheet using one of its columns as
key.  Here's a simple example:

age<-c(22, 57, 13)
zipcode<-(50854, 20617, 91234)
If we sort the name vector in zipcode order we should get
mary, joe, sue
If we sort name in age order we should get sue, joe, mary
Having secondary keys to break ties would be nice, as would
the ability to sort (in this example)
all 3 vectors at once.

Any help appreciated.
Art Salwin
salwin at mitretek.org
(202) 863-2985
(202) 863-2988 (fax)
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

More information about the R-help mailing list