my array looks like this:
to_sort = [[1, 27, -3, 1.0], [2, 27, -2, 2.0], [3, 27, -2, 3.0], [4, 27, -2, 4.0],
[5, 27, -2, 5.0], [6, 27, 1, 11.0], [7, 27, 1, 12.0], [8, 27, 1, 13.0],
[9, 27, 2, 14.0]]
I would like to sort these arrays based on their second and third values in ascending order, but the arrays possessing a negative number for the third number must be sorted decreasingly and placed after the other arrays.
The result should be something like this:
sorted = [[6, 27, 1, 11.0], [7, 27, 1, 12.0], [8, 27, 1, 13.0], [9, 27, 2, 14.0],
[2, 27, -2, 2.0], [3, 27, -2, 3.0], [4, 27, -2, 4.0], [5, 27, -2, 5.0],
[1, 27, -3, 1.0]]
How can it be done to be as optimized as possible?