Jul-30-2018, 05:50 PM
Can someone explain what is happening in the following sorting action:
I have a list:
I have a list:
L = ['breathe', '_', 'd', '+', 'a', 'bear']If i sort it with the key parameter checking if there is an item in the list:
sorted(l,key=lambda x: x=="a")"a" is replaced as the last item in the sorted list:
['breathe', '_', 'd', '+', 'bear', 'a']What is happening?