'Kotlin android highscore combing all instances of score into highscore

I am trying to achive the following:

enter image description here

If you can't see the picture I am basically trying to get the instances of each point gained into another list that combines the total points and lists them according to user

This is as far as I got

private lateinit var recyclerviewFrag : RecyclerView
private lateinit var kotlinPointsData: ArrayList<KotlinPointsData>

              kotlinPointsData.sortBy {
              pointsData -> pointsData.totalpoints
                //if(pointsData.username.duple)
            }
val highscoreList = kotlinPointsData.groupBy { it.username}.forEach{points as
}




recyclerviewFrag.adapter = PointsKotlinAdapter(kotlinPointsData)


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source