#Sort .json by values (highest to lowest)

4 messages · Page 1 of 1 (latest)

potent cairn
#

Hi I want to create a leaderboard with a .json file.
My .json File looks like this

{"1025877489957994529":{"name":"Tisch 8","time":15} {"1025877489957991239":{"name":"Tisch 9","time":23}
...

Now I want to create a leaderboard with a ranking (highest to lowest value)
How is it possible to sort this values
Thx 🙂

spring meadowBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

spring meadowBOT
#

mdn JSON.parse()
The JSON.parse() method parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

#

mdn Array.prototype.sort()
The sort() method sorts the elements of an array in place and returns the reference to the same array, now sorted. The default sort order is ascending, built upon converting the elements into strings, then comparing their sequences of UTF-16 code units values.