Python: Sort custom class without use of `key` argument?
<p>You can sort an array of <code>myclass</code> by using the <code>key</code> argument to the <code>sorted</code> function:</p>

<pre><code>sortedlist = sorted(myclasses, key=lambda obj: obj.myproperty)
</code></pre>

<p>Is there a way to define a natural ordering for our class? Perhaps some magic method so that we don't have to pass in a key each time?</p>

<p>e.g.,</p>

<pre><code>class myclass:
    def __init__(self,a,b):
        self.key1 = a
        self.key2 = b

    def __sortkey__(self):
        return self.key2
</code></pre>

<p>Or will it naturally work if we define <code>__le__</code> perhaps?</p>
