Python JSON array as show in example
[{
"id":"3",
"creator_id":"2131xxxxxxxx",
"lowest_price_at":"2021-01-21T09:29:38-08:00",
"status":"published",
"status_changed_at":"2021-02-09T23:59:34-08:00",
"origin_domain":"us"
},
{
"id":"5",
"creator_id":"2131xxxxxxxx",
"lowest_price_at":"2021-01-15T09:29:38-08:00",
"status":"published",
"status_changed_at":"2021-02-09T23:59:34-08:00",
"origin_domain":"us"
},
{
"id":"1",
"creator_id":"2131xxxxxxxx",
"lowest_price_at":"2021-01-5T09:29:38-08:00",
"status":"published",
"status_changed_at":"2021-02-09T23:59:34-08:00",
"origin_domain":"us"
}]
It's contained in live_items array.
Now I need to sort that array by status_changed_at
descending.
Meaning first item in array needs to be the one with "id":"1"
from datetime import datetime
print(sorted(live_items, key=lambda x['status_changed_at']: datetime.strptime(x['status_changed_at'], "%Y-%m-%dT%H:%M:%S-08:00").strftime("%b %d %Y %I:%M%p")))
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
This I found on the thread sort dates in python array but I just stuck since i use first time lambda ex..