I have a list of vectors looking like:
[[1]] [1] 2 1.0 3.0 [[2]] [1] 3 3 3 [[3]] [1] 1 3.0 1.0
and I want it to be sorted by first elemen
Same as the others but using Map to extract the first element of each vector.
L <- list(c(2,1,3), c(3,3,3), c(1,3,1)) idx <- as.numeric(Map(function(vec){vec[1]},L)) L[order(idx, decreasing=TRUE)]