sorting a list of dicts by a computed field
Larry Martell
larry.martell at gmail.com
Tue Jan 31 15:26:05 EST 2017
I have a list of dicts and one item of the dict is a date in m/d/Y
format. I want to sort by that. I tried this:
sorted(data['trends'], key=lambda k:
datetime.strptime(k['date_time'],'%m/%d/%Y'))
But that fails with:
Exception Type: AttributeError at /report/CDSEM/WaferAlignment/ajax/waChart.json
Exception Value: 'module' object has no attribute 'strptime'
How can I do this sort?
More information about the Python-list
mailing list