Hi This might sounds confusing, but I will try to explain best I can. My list of dictionaries looks like this:
{
"1": {
"bd_date": "04/02/1977",
"name": "Deli Mirko",
"next": "04/02/2021",
"renew": 1,
"type": "birthday",
"until": 1
},
"-MScOoqCpbVxSpz56j0B": {
"bd_date": "25/11/1983",
"name": "Deli Marina",
"next": "25/11/2021",
"renew": 1,
"type": "birthday",
"until": 295
},
"-MScWwQ6-23Sdd50YoQh": {
"bd_date": "17/04/1952",
"name": "Deli Geza",
"next": "17/04/2021",
"renew": 1,
"type": "birthday",
"until": 73
}
}
I wish to sort this using "until" values ASC.
Is there a way to do this.
EDIT: I tried suggested solutions, but I don't get result OR it changes my dictionary format. I need to keep format, because the rest of code. I tried
new_list = sorted(old_list.items(), key=lambda i: i[1]['until'])
but it changes format to list from dict - [("x",{...}), ("y",{..})...]
how to change above code to keep format {"x": {...}, "y": {...}}