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