How do I find the key for the latest date value of a dictionary where the dates are represented as strings?
I tried using max(date, key=date.get)
as in Getting key with maximum value in dictionary?, but it returns wrong results:
date = {"sale_date": "2018-02-17 20:11:37.017298",
"buy_date": "2018-02-2 20:11:37.017298"}
latest = max(date, key=date.get)
This returns "buy_date"
but clearly the result should be "sale_date"
.