sort list of dictionaries python by value
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
sort list of dictionaries python by value
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
python sort dict by value
A={1:2, -1:4, 4:-20}
{k:A[k] for k in sorted(A, key=A.get)}
output:
{4: -20, 1: 2, -1: 4}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us