Please help me sort the date time dictionary in the Python list

Asked 2 years ago, Updated 2 years ago, 13 views

date_list = [{"date":"2019-05-12"},{"date":"2019-05-10"},
             {"date":"2019-05-14"},{"date":"2019-05-20"},
             {"date":"2019-03-12"},{"date":"2019-08-12"}]

In this way, how can we sort by date when the date-time dictionaries in the list are randomly placed?

python

2022-09-22 08:38

1 Answers

sorted(date_list, key=lambda e:e['date'])


2022-09-22 08:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.