Sorting list of list of elements of a custom class in R?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: I have a custom class object (list of tuples). I have defined <.myclass >.myclass and ==.myclass on it as well. Now I have a a <- obj1 # of myclass b <- obj2 # of myclass c <- obj3 # of myclass L <- list ( list ( a , 12 , 1 ), list ( b , 215 , 23 ), list ( c , 21 , 9 )) I want to sort L, on index 1. i.e. I have b < c < a then, I want sorted L in this form list(list(b,215,23),list(c,21,9),list(a,12,1)) How do I achieve this? In my searches, I found how to sort on particular index, and using that I wrote the following function magic