title: Sorting a csv object by dates in python
body: <p>I am trying to read and sort a csv file that has data that looks like</p>
  
  <pre><code>Date    Open    High    Low Close   Volume
  27-Mar-12   8.25    8.35    8.17    8.19    9801989
  26-Mar-12   8.16    8.25    8.12    8.24    8694416
  23-Mar-12   8.05    8.12    7.95    8.09    8149170
  </code></pre>
  
  <p>I do this with</p>
  
  <pre><code>import csv
  data = csv.reader(open('data.csv','r'))
  </code></pre>
  
  <p>To sort data by Date. I do:</p>
  
  <pre><code>sorteddata = sorted(data,key=operator.itemgetter(1),reverse=False)
  </code></pre>
  
  <p>The problem is, that it sorted the dates by reading them as String and not as dates. So the data is sorted like so,</p>
  
  <pre><code>['3-Aug-11', '7.06', '7.23', '6.84', '7.16', '31583617']
  ['3-Feb-12', '7.02', '7.12', '6.98', '7.08', '15318044']
  ['3-Jan-12', '5.53', '5.59', '5.44', '5.48', '12678923']
  ['3-Jun-11', '8.09', '8.17', '7.92', '7.97', '21273812']
  ['3-May-11', '9.00', '9.04', '8.63', '8.80', '17356005']
  </code></pre>
  
  <p>Does anybody know how to sort by dates?</p>