how python sort's key works :     class Solution(object):
        def moveZeroes(self, nums):
            nums.sort(key =lambda x : 1 if x == 0 else 0)
            return nums

i have function above, i don't understand how code `key =lambda x : 1 if x == 0 else 0`  works. 

i tried to change the lambda function to something i know, like below:


    def getKey(item):
        if item == 0:
            return 1
        else:
            return 0

But i quite don't understand how key which equals to 1 or 0 affects the result.