title: Order list by date (String and datetime)
body: <pre><code>import csv,operator
  from datetime import datetime
  
  li = [['name','01/03/2012','job'],
        ['name','02/05/2013','job'],
        ['name','03/08/2014','job']]
  </code></pre>
  
  <h2>Sorted Method:</h2>
  
  <pre><code>sorted(li,key=lambda x:datetime.strptime(row[1],'%d/%m/%Y'), reverse=True)
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <p>No error, but simply not ordered</p>
  
  <h2>Itemgetter Method:</h2>
  
  <pre><code>for x in range(1,len(li)):
      li[x][6]=datetime.strptime(li[x][6],'%d/%m/%Y')
  
  li.sort(key=operator.itemgetter(6))
  </code></pre>
  
  <p><strong>Output:</strong></p>
  
  <pre><code>Traceback (most recent call last):
    File "U:/rmarshall/Work For Staff/ROB/_Python/__Python Projects Code/April Signed Terms.py", line 35, in &lt;module&gt;
      li.sort(key=operator.itemgetter(6))
  TypeError: unorderable types: datetime.datetime() &lt; str()
  </code></pre>
  
  <p>Could someone supply an example of ordering a the list li by date.  For educational purposes I would appreciate examples of both the sorted method and itemgetter method with a comparison of efficiency.</p>
  
  <p>Also, by the error on the itemgetter approach, is itemgetter simply not able to handle datetime objects.</p>
  
  <p>Note:  I presume the ascending or descending order doesn't matter too much in this example as it can be simply flipped with <code>reverse=True</code>.</p>