I have a list of email objects. It contains DateTime in the following format:
Thu, 17 Dec 2020 15:30:15 +0100
When I try to sort the list using sorted(), it only sorts by the time.
sorted_emails = sorted(emails,key=lambda email: email['Date'],reverse=True)
for item in sorted_emails:
print(item['Date'])
Outputs:
Wed, 16 Dec 2020 21:59:45 +0100
Wed, 16 Dec 2020 21:58:22 +0100
Wed, 16 Dec 2020 12:29:39 +0100
Wed, 16 Dec 2020 12:29:13 +0100
Wed, 16 Dec 2020 12:28:41 +0100
Wed, 16 Dec 2020 12:26:50 +0100
Wed, 16 Dec 2020 12:26:17 +0100
Wed, 16 Dec 2020 12:25:57 +0100
Thu, 17 Dec 2020 15:30:15 +0100
Sat, 12 Dec 2020 21:17:35 +0100
How would I make it sort accounting for the date as well?