I misunderstood what you want, I thought that a given player might have multiple entries in the database, in this case, you can ignore the first loop.
wixData.query('POINTS').eq('player','Ahmad').find().then((result) => {
const player = result.items[0] || null;
if (player) {
const points = [];
for (let i = 1; i <=6; i++) {
points.push(player[`points${i}`]);
}
points.sort((a, b) => {
return b - a;
})
const final_points = points.slice(0, 5);
}
})
Now you have the highest 5 points out of 6 for the player “Ahmad” stored in an array and sorted descendingly, how you save them is completely up to you.