sorting - Sort list by values preserving names in R -


consider list l like:

l<-list(a=24,b=12,c=30,d=1) 

how sorted version on values of such list, preserving names?

in result list order of elements should then: d,b,a , c corresponding sequence 1,12,24,30.

you can use order. assuming length of each list element 1 showed in example

l[order(unlist(l))] 

Comments

Popular posts from this blog

java - Solr query version issue: Invalid version or the data in not in 'javabin' format -

Hard vs. Soft Water: What's The Difference?

The Ten Most Livable Cities In The World