With the following input:
[5,5,4,4,4,2,2,1]
I want to generate the following output:
[
{
"points": 5,
"rank": 1
},
{
"points": 5,
"rank": 1
},
{
"points": 4,
"rank": 3
},
{
"points": 4,
"rank": 3
},
{
"points": 4,
"rank": 3
},
{
"points": 2,
"rank": 6
},
{
"points": 2,
"rank": 6
},
{
"points": 1,
"rank": 8
}
]
I found a solution (see the response) but I wonder if is there a better way to do it.