list.sort, sorted, and similar methods currently have a "key" argument that accepts a callable. Often, that leads to code looking like this:<br><br>mylist.sort(key=lambda x: x[1])<br>
myotherlist.sort(key=lambda x: x.length)<br><br>I would like to propose that the "key" parameter be generalized to accept str and int types, so the above code could be rewritten as follows:<br><br>mylist.sort(key=1)<br>
myotherlist.sort(key='length')<br><br>I find the latter to be much more readable. As a bonus, performance for those cases would also improve.<br><div style="margin: 2em 0pt;" name="sig_2341e11ee1">--<br>
Daniel Stutzbach<a href="http://stutzbachenterprises.com"></a>
</div>