I have a JSON file, and what I want to do is make a function in which I return an ordered list limited by 10 users (if possible, in an array, but if that is complicated, I would appreciate your suggestion).
This data comes from:
let points = JSON.parse(fs.readFileSync('./points.json', 'utf8'));
In which I access the data of each one with the following line:
let userData = points[msg.author.id];
The JSON file has the following format.
{
"242043489611808769":{"points":617,"level":4,"time":1482316617392},
"129213229221019648":{"points":22,"level":0,"time":1482316617609},
"190388892799598592":{"points":214,"level":2,"time":1482316612355}
}
At the moment, what I have is a program that does is add points to users (and as they reach 'x' points, automatically level up), but now I need to make a list of the top 10 most users assets ".
What I need is that when ordering, return the ID (in the first case it would be 242043489611808769 ), which is what I need to be able to process the data.
Work with NodeJS, thanks in advance.