I'm trying to sort my list of list with a.sort(key=lambda x: x[0]) or a.sort(). The first element of my date is the day and I need to sort by it.
a = [['1/8/2018', 71], ['10/8/2018', 76], ['11/8/2018', 6], ['12/8/2018', 60], ['13/8/2018', 81], ['14/8/2018', 74], ['15/8/2018', 7], ['16/8/2018', 77], ['17/8/2018', 81], ['18/8/2018', 69], ['19/8/2018', 66], ['2/8/2018', 81], ['20/8/2018', 74], ['21/8/2018', 88], ['22/8/2018', 92], ['23/8/2018', 90], ['24/8/2018', 84], ['25/8/2018', 66], ['26/8/2018', 64], ['27/8/2018', 82], ['28/8/2018', 82], ['29/8/2018', 79], ['3/8/2018', 8], ['4/8/2018', 64], ['5/8/2018', 64], ['6/8/2018', 12], ['7/8/2018', 8], ['8/8/2018', 83], ['9/8/2018', 77]]
the results I need:
[['1/8/2018', 71],['2/8/2018', 81], ['3/8/2018', 8], ['4/8/2018', 64], ['5/8/2018', 64], ['6/8/2018', 12],['7/8/2018', 8], ['8/8/2018', 83], ['9/8/2018', 77], ['10/8/2018', 76], ['11/8/2018', 6], ['12/8/2018', 60], ['13/8/2018', 81], ['14/8/2018', 74], ['15/8/2018', 7], ['16/8/2018', 77], ['17/8/2018', 81], ['18/8/2018', 69], ['19/8/2018', 66], ['20/8/2018', 74], ['21/8/2018', 88], ['22/8/2018', 92], ['23/8/2018', 90], ['24/8/2018', 84], ['25/8/2018', 66], ['26/8/2018', 64], ['27/8/2018', 82], ['28/8/2018', 82], ['29/8/2018', 79]]
stringinstead ofnumbersordates. Try to convert that intodatethan do your stuff.