How to properly do a ranked checkpoint system

basically I’m trying to make a checkpoint system which displays the rank (1st, 2nd, 3rd) on the players screen.

this is code so far:

for i, checkpoint in ipairs(workspace:WaitForChild("Checkpoints"):GetChildren()) do
		checkpoint.Touched:Connect(function(hit)
			local char = hit.Parent
			local hum = char:FindFirstChild("Humanoid")
			
			if hum then
				local plr = plrS:GetPlayerFromCharacter(char)
				plr:WaitForChild("Data").Checkpoint.Value = tonumber(checkpoint.Name)
				for i, plr in ipairs(plrS:GetPlayers()) do
					local checkpoint = plr:WaitForChild("Data").Checkpoint

					plrCheckpoints[plr.Name] = checkpoint.Value
				end
				
				table.sort(plrCheckpoints, function(a, b)
					return a > b
				end)
				
				for i, v in plrCheckpoints do
					print(v)
				end
				
				local place = 0
			
				for plar, check in plrCheckpoints do
					--place += 1
					print(plar, check)
					--print(plar, place.."Checkpoint: "..check)
					--[[if i == plr.Name then
						print(plr.Name)
					end]]
				end

				--local gui = plr.PlayerGui.ScreenGui.Holder.Frame.TextLabel

				--gui.Text = places[place]
			end
		end)
	end

the problem with this is that the table.sort doesn’t properly sort the list as the first player that is added to the list is always at the top, how could I change my script to make it work?

Hello! You’ll have to create your own sorting function, I don’t think table.sort can help you in this situation.