I have a list below:
arr = [1,3,-10, -4, 4,10,30, -30]
I want to call arr.sort and sort these values based on the absolute value and such that if the absolute values are equal then the negative value should come first like below:
[1, 3, -4, 4, -10, 10, -30, 30]
I know I have a few ways to do this namely wrapping my own class around this and operator overload it. But without this, is there an easier way to do so by just using the key parameter?