Script displays x2 pet with the same %

Hello developers!

I want to sort pets from the highest % to the lowest % but when 2 pets have the same % then script display x2.

This is how it looks:

Script:

for i, v in pairs(Eggs:GetChildren()) do
	local eggPets = Pets:FindFirstChild(v.Name)
	
	if eggPets ~= nil then
		local bilboardTemp = script.Template:Clone()
		local container = bilboardTemp:WaitForChild("Container")
		local MainFrame = container:WaitForChild("MainFrame")
		local Template = MainFrame:WaitForChild("Template")
		local Display = Template:WaitForChild("Display")
		
		bilboardTemp.Parent = script.Parent.Parent.EggBilboards
		bilboardTemp.Name = v.Name
		bilboardTemp.Adornee = v.DisplayPet
		bilboardTemp.Enabled = true
		container.Price.Text = "⚡"..v.Price.Value
		
		
		local pets = {}
		
		for x, pet in pairs(eggPets:GetChildren()) do
			table.insert(pets, pet.Rarity.Value)
		end
		
		local sort = table.sort(pets, function(a, b)
			return a > b
		end)
		
		for _, rarity in pairs(pets) do
			for _, pet in pairs(eggPets:GetChildren()) do
				if pet.Rarity.Value == rarity then

					local rarity = pet.Rarity.Value
					
					
					local clonedTemp = Template:Clone()

					clonedTemp.Name = pet.Name
					clonedTemp.Rarity.Text = tostring(pet.Rarity.Value).."%"
					clonedTemp.Visible = true
					clonedTemp.Parent = MainFrame

					local petModule = module3d:Attach3D(clonedTemp.Display,pet:Clone())
					petModule:SetDepthMultiplier(1.2)
					petModule.Camera.FieldOfView = 5
					petModule.Visible = true

					runService.RenderStepped:Connect(function()
						petModule:SetCFrame(CFrame.Angles(0,-5,0) * CFrame.Angles(math.rad(-10),0,0))
					end)
				end
			end
		end
	end
end

Here you may be inserting rarities that have the same value. E.g., pets = {60, 60, 10, 5}

local pets = {}

for x, pet in pairs(eggPets:GetChildren()) do
	table.insert(pets, pet.Rarity.Value)
end

local sort = table.sort(pets, function(a, b)
	return a > b
end)

Fix:

local pets = {}

for x, pet in pairs(eggPets:GetChildren()) do
    local rarityValue = pet.Rarity.Value
    if not table.find(pets, rarityValue) then
	    table.insert(pets, rarityValue)
    end
end

local sort = table.sort(pets, function(a, b)
	return a > b
end)

This causes an issue because of these 2 nested for loops. If you have 2 pets of identical rarity (e.g., 60%), 60% will have 2 entries in pets. This will run the inner for loop twice for each of these 2 pets.

		for _, rarity in pairs(pets) do
			for _, pet in pairs(eggPets:GetChildren()) do