title: How to use a custom comparison function in Python 3?
body: <p>In <strong>Python 2.x</strong>, I could pass custom function to sorted and .sort functions</p>
  
  <pre><code>&gt;&gt;&gt; x=['kar','htar','har','ar']
  &gt;&gt;&gt;
  &gt;&gt;&gt; sorted(x)
  ['ar', 'har', 'htar', 'kar']
  &gt;&gt;&gt; 
  &gt;&gt;&gt; sorted(x,cmp=customsort)
  ['kar', 'htar', 'har', 'ar']
  </code></pre>
  
  <p>Because, in <em>My</em> language, consonents are comes with this order</p>
  
  <pre><code>"k","kh",....,"ht",..."h",...,"a"
  </code></pre>
  
  <p>But In <strong>Python 3.x</strong>, looks like I could not pass <code>cmp</code> keyword</p>
  
  <pre><code>&gt;&gt;&gt; sorted(x,cmp=customsort)
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  TypeError: 'cmp' is an invalid keyword argument for this function
  </code></pre>
  
  <p>Is there any alternatives or should I write my own sorted function too?</p>
  
  <p><sub>Note: I simplified by using "k", "kh", etc. Actual characters are Unicodes and even more complicated, sometimes there is vowels comes before and after consonents, I've done custom comparison function, So that part is ok. Only the problem is I could not pass my custom comparison function to sorted or .sort</sub></p>