'TypeError: '<' not supported between instances of 'dict' and 'dict' Making leaderboard using json and discord.py

I am fairly new here so I apologise if this post is not up to your standards.

To summarise the problem, I am using Json and Discord.py to create a level leader-board. I seem to not be able to sort the values in the json database as they are dictionary values, any help would be greatly appreciated.

Screenshots of code and errors:

Code screenshot

Json database screenshot

Error screenshot



Solution 1:[1]

Get the values you want from the dictionary as a tuple, and use that as the key.

sorted(users.items(), key = lambda item: (item[1]['level'], item[1]['currency'], item[1]['experience'], reverse=True)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Barmar