Top-rated recipes tagged "2_to_3"http://code.activestate.com/recipes/tags/2_to_3/top/2010-04-04T23:28:40-07:00ActiveState Code RecipesConvert a cmp function to a key function (Python)
2010-04-04T23:28:40-07:00Raymond Hettingerhttp://code.activestate.com/recipes/users/178123/http://code.activestate.com/recipes/576653-convert-a-cmp-function-to-a-key-function/
<p style="color: grey">
Python
recipe 576653
by <a href="/recipes/users/178123/">Raymond Hettinger</a>
(<a href="/recipes/tags/2_to_3/">2_to_3</a>).
Revision 5.
</p>
<p>Py3.0 transition aid. The <em>sorted()</em> builtin and the <em>list.sort()</em> method no longer accept a <em>cmp</em> function in Python 3.0. Most cases are easy to convert manually. This recipe handles the remaining cases.</p>