Filtering numbers

Hello,

i have following:
1 person with 5 different points
1 person with 5 different points
total 10 separate point fields
both these 2 persons is a team.

i need to filter final team points.
team points are 5 largest points from those 10 fields.

Basicaly i need to write function that filters these 10 fields , gets 5 largest numbers, sums them up and delivers final number.

example:
1person points:
10, 20, 30, 40, 50
2 person points:
50, 40, 30, 20, 10

5 highest points of them are:
50, 50, 40, 40, 30

result:
210

I have been spinning my head and came with no ideas at all apart lots of manual inputs.

@ahmadnasriya can you bring me on the road?

Where do you have these “points”? In an array? An object?

If it’s an array, you can sort the array and then just use the 5 highest values in the array.