How to find out which player has the most frags most efficent?

Currently how I think it has to be done is looping through all players and then inserting everyone into a with frag and uniqueid. Then loop through the table while looping through all players inside that table to find out who has the most frags.

But that’s really complicated and stupid to loop through a total of 3 tables which can each have a lot of indexes, so is it possible to do it better?

[lua]
local plys = player.GetAll()

table.sort(plys, function(a, b)
return a:Frags() > b:Frags()
end)

local winner = plys[1]
[/lua]

Well thanks, never worked a lot with tables.