How to create sort with conditions in python? Say if I have a list
a: [-1, 3, 4, 2, -1, -1, 1, 0]
How to sort only those elements that are not equal to -1? (In reply:
[-1, 0, 1, 2, -1, -1, 3, 4] )
How to sort all other items? (In response to a :) [-1, 3, -1, 2, 1, -1, 4, 0]
The code syntax is incorrect, but does it look like something like that?
result=sorted(a, key=lambda x: x!=-1,reverse=True)
result=sorted(a, key=lambda x: [::2],reverse=True)