Sorting a list of objects by attribute
<p>I am trying to sort a list of objects in python, however this code will not work:</p>

<pre><code>import datetime

class Day:
    def __init__(self, date, text):
        self.date = date
        self.text = text

    def __cmp__(self, other):
        return cmp(self.date, other.date)

mylist = [Day(datetime.date(2009, 01, 02), "Jan 2"), Day(datetime.date(2009, 01, 01), "Jan 1")]
print mylist
print mylist.sort()
</code></pre>

<p>The output of this is:</p>

<pre><code>[&lt;__main__.Day instance at 0x519e0&gt;, &lt;__main__.Day instance at 0x51a08&gt;]
None
</code></pre>

<p>Could somebody show me a good way solve this? Why is the <code>sort()</code> function returning <code>None</code>?</p>
