In python, I can do something like
a = [1,100,5,-5,-7,99,-100]
a.sort(key= lambda x: (x<0,abs(x)))
It gives me
[1, 5, 99, 100, -5, -7, -100]
It is sorted by positive/negative number and abs value.
How can I do the same thing in R? Without splitting into positive and negative numbers?
a = c(1,100,5,-5,-7,99,-100)