I have a array that contains users their names and money. What I am trying to do is to sort the array by money in descending order, so that I can make a leaderboard for who has the most money.
This is my current code:
@client.command()
async def score(ctx):
channel = ctx.message.channel
data = loadjson()
scoreboard = []
Minimum_money = 0
for line in data:
Current_name = line["name"]
Current_money = line["money"]
if Current_money > Minimum_money:
value = Current_name + " " + str(Current_money)
scoreboard.append(value)
elif not scoreboard:
scoreboard.append("Empty!")
return print(scoreboard)
And this is the output I get:
The output I get is alright, the numbers just need to be in descending order. I searched for a solution but couldn't find anything, it feels like an easy fix but I have no idea on what to do.