title: Working of python's sort key
body: <pre><code>class Solution(object):
      def moveZeroes(self, nums):
          nums.sort(key =lambda x : 1 if x == 0 else 0)
          return nums
  </code></pre>
  
  <p>My function looks like above.
  I don't seem to understand how code <code>key =lambda x : 1 if x == 0 else 0</code>  works. </p>
  
  <p>I also tried to change the lambda function to:</p>
  
  <pre><code>def getKey(item):
      if item == 0:
          return 1
      else:
          return 0
  </code></pre>
  
  <p>But don't seem to understand how key=1 or 0, affects the result.</p>