[R] sorting a list structure based on one of its components

Gabor Grothendieck ggrothendieck at myway.com
Thu Nov 27 06:44:01 CET 2003


Assuming you want to order the components of my.list according
to the order of the third one:

lapply( my.list, function(x) x[order(my.list[[3]])] )



 --- On Thu 11/27, Rajarshi Guha < rxg218 at psu.edu > wrote:
From: Rajarshi Guha <rxg218 at psu.edu>
To: R <r-help at stat.math.ethz.ch> 
Subject: [R] sorting a list structure based on one of its components 

 
 
Hi,
is the following possible?

I have a list of vectors which may be numeric or character. Is there any
way I can sort all the vectors based on a certain numeric vector?

Thanks,




More information about the R-help mailing list