Suppose I have a vector v
, how do I get its reverse, i.e. last element first?
The first thing that comes to me is v[length(v):1]
, but it returns NA when v
is numeric(0)
, while user normally expect sorting nothing returns nothing, not sorting nothing returns the unavailable thing - it does make a big difference in my case.