3

I have a list of objects {key, value} pairs. For example:

list.predict

[[1]]

[1] 1.0000000 0.8564264

[[2]]

[1] 2.0000000 0.1980792

I want to sort this list in descending order by the second component of each element (meaning sorting on the sequence of 0.8564264 and 0.1980792).

user3628777
  • 529
  • 3
  • 10
  • 20

1 Answers1

3
list.predict[ order( sapply(list.predict, "[", 2) ) ]
IRTFM
  • 258,963
  • 21
  • 364
  • 487