Need help finding player with the most of a stat

Ok so in a game I am making there will be a Mayor, and the Mayor is chosen by the person that has been in the game the longest, I already have a system made to give points to the people in the game longer and to remove them from the Mayor. I just can’t figure out how to find out who has the most and how to make them the Mayor when the current one dies. Anyone know how to do this?

Also I want this code to run when the current Mayor dies, and to remove them from the team.

To find the player with the most points, get a table with all the players and have an empty variable to store which player has the most. Then, you can iterate through the table and compare each player to the player with the highest. If they have more points, set the variable to that player. To incorporate a Mayor dying, just remove that player from the table at the start.

Any chance you could describe what this looks like? I honestly have no clue how to write this. I haven’t worked with tables before. Still a beginner lol