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)

From your diagram, you have a username, with a point

data class User(val username: String, val points: Int)

You then want to create a new list containing the user along with the sum of all user points

data class TotalPointsUser(val totalPoint: Int, val user: User)
// list of users and their points
val users = listOf(
    User("1", 10),
    User("2", 7),
    User("3", 9),
    User("4", 7),
    User("5", 7),
    User("6", 9),
    User("7", 8),
)

// get sum of all points
val totalPoints: Int = users.sumOf { user: User -> user.points }

// create a new list with each user and the total points
val usersAndPoints: List<TotalPointsUser> = users.map { user: User -> TotalPointsUser(totalPoints, user) }