My list looks something like this:
I have converted the string values (such as rs267) to numbers but when I try:
lapply(list, function(x) sort(x))
My data ends up being sorted by the values of the list. But I want it to be sorted by the name values, since these are numeric.
CodePudding user response:
Convert the names
(character
) to numeric
, apply order
and use that index for ordering the list
list[order(as.numeric(names(list)))]