title: Remove older elements from a list
body: <p>I'm trying to remove similar elements from a list that contains a sub_list with the elements' name, date, and additional data: </p>
  
  <p><code>basket = [['cheese', '2015/04/16', 'junk'],['apple', '2015/04/15', 'other junk'],['apple', '2015/03/15', 'dessert'],['cheese', '2017/04/16', 'pie'],['banana', '2015/04/16', ''],['cheese', '2017/04/10', '']]</code></p>
  
  <p>If an element name (fruit) appears twice in the list, the program should compare the date and remove the older element. I'm using <strong>datetime</strong> to compare the the second element and this part is working. But when I iterate through the list, it keeps skipping <code>'banana'</code>. And this should be the last item to be added.</p>
  
  <p>I've tried this method:</p>
  
  <pre><code>def date_convert(date):
      """Takes a date string in the form YYYY/MM/DD and converts it to a
         date object for comparisons."""
  
      # Split date string by ".", " ", "/", or "-" to handle a wider range
      # of possible inputs.
      date = re.split('[. /\-]', date)
  
      # Strip month of "0" because datetime does not accept that as valid
      # input.
      if(date[1][0] == '0'):
          date[1] = date[1].strip('0')
  
      return datetime.date(int(date[0]), int(date[1]), int(date[2]))        
  
  
  
  
  basket = [['cheese', '2015/04/16'],['apple', '2015/04/15'],['apple', '2015/03/15'],['cheese', '2017/04/16'],['banana', '2015/04/16'],['cheese', '2017/04/10']]
  
  new_basket = []
  
  for food in basket:
      basket.remove(food)
      for food2 in basket:
          if food[0].upper() == food2[0].upper():
              basket.remove(food2)
  
              if date_convert(food[1]) &gt; date_convert(food2[1]):
                  pass
              else:
                  food = food2
      else: new_basket.append(food)
  
  print str(new_basket)
  </code></pre>
  
  <p>and receive this printout: <code>[['cheese', '2017/04/16', 'pie'], ['apple', '2015/04/15', 'other junk']]</code></p>
  
  <p>According to the debugger, it never reaches banana in the for loop.</p>