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

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -