title: Sorting function in Python 3
body: <p>I would like to use an older python script with <code>cmp</code> function, but it doesn't work in Python 3. It raises an error:</p>
  
  <pre><code>TypeError: must use keyword argument for key function 
  </code></pre>
  
  <p>I know that I should avoid the <code>cmp</code> function and use the key function instead, but I don't know how (I don't know Python and I am not a programmer). Could you please help me to change the following part according to <a href="https://docs.python.org/3/howto/sorting.html" rel="nofollow noreferrer">this</a>?</p>
  
  <pre><code>ls = list(self.entries)
  
  def func(key1, key2):
      (w1,l1,t1) = res[key1]
      (w2,l2,t2) = res[key2]
      val = cmp((w2,t2), (w1,t1))
      return val
  ls.sort(func)
  </code></pre>
  
  <p>Thank you.</p>