python sort list of dicts by value code example Example: sort dict by value dict(sorted(x.items(), key=lambda item: item[1]))