Sorting pets in an egg

my pets are sorted alphabetically in my egg, that is, by the first letter of the pets, and I need to sort by chances, please help

export type Egg = { Price: number, Pets: { [string]: number } }

return {
	Common = {
		Price = 300,
		Area = 'Spawn',
		Pets = {
			Dog = 50,
			Cat = 35,
			Bunny = 10,
			Bear = 5,
		},
	},

	Rare = {
		Price = 2500,
		Area = 'Spawn',
		Pets = {
			Fox = 50,
			Bull = 35,
			Lizard = 5,
			Deer = 10,
		},
	},

	Desert = {
		Price = 10000,
		Area = 'Desert',
		Pets = {
			['Desert Dog'] = 50,
			['Desert Bull'] = 35,
			['Desert Lizard'] = 10,
			['Desert Dragon'] = 5,
		},
	},

	Lake = {
		Price = 35000,
		Area = 'Lake',
		Pets = {
			['Frog'] = 50,
			['Blue Frog'] = 35,
			['Yellow Frog'] = 10,
			['Red Frog'] = 5,
		},
	},

	Candy = {
		Price = 75000,
		Area = 'Candy',
		Pets = {
			['Ice Cream Doggy'] = 50,
			['Ice Cream Kitty'] = 35,
			['Ice Cream Mouse'] = 10,
			['Ice Cream Bat'] = 5,
		},
	},

	Volcano = {
		Price = 120000,
		Area = 'Volcano',
		Pets = {
			['Lava Plume'] = 50,
			['Lava Golem'] = 35,
			['Plume Family'] = 10,
			['Lava Master'] = 5,
		},
	},

	Atlantic = {
		Price = 280000,
		Area = 'Atlantic',
		Pets = {
			['Atlantic Dog'] = 50,
			['Atlantic Kitty'] = 35,
			['Atlantic Bunny'] = 10,
			['Atlantic Bear'] = 5,
		},
	},

	Cemetery = {
		Price = 600000,
		Area = 'Cemetery',
		Pets = {
			['Cemetery Phoenix'] = 50,
			['Cemetery Megalodon'] = 35,
			['Cemetery Varan'] = 10,
			['Cemetery Unicorn'] = 5,
		},
	},

	Toy = {
		Price = 1000000,
		Area = 'Toy',
		Pets = {
			['Toy Doggy'] = 50,
			['Toy Kitty'] = 35,
			['Toy Deer'] = 10,
			['Toy Omega Bull'] = 5,
		},
	},

	Mage = {
		Price = 1700000,
		Area = 'Mage',
		Pets = {
			['Galactic System'] = 50,
			['Galactic Hedgehog'] = 35,
			['Galactic Saturn'] = 10,
			['Galactic Queen'] = 5,
		},
	},

	Autumn = {
		Price = 5000000,
		Area = 'Autumn',
		Pets = {
			['Star Plate'] = 50,
			['Super Star'] = 35,
			['Super Eclipsa'] = 10,
			['Super Prism'] = 5,
		},
	},
	
	

	-- ===========================================================================
	-- Robux
	-- ===========================================================================
	Robux = {
		Price = 249,
		Area = 'Spawn',
		Robux = true,

		DevProducts = {
			[1] = 1268781517,
			[3] = 1268781668,
		},

		Pets = {
			['Black Serpent'] = 85,
			['Black Exoticis'] = 25,
		},
	},

	['Super Op'] = {
		Price = 1299,
		Area = 'Spawn',
		Robux = true,

		DevProducts = {
			[1] = 1268781849,
			[3] = 1268781909,
		},

		Pets = {
			['HearthCup'] = 100,
		},
	},
	
	['Super Op'] = {
		Price = 149,
		Area = 'Spawn',
		Robux = true,

		DevProducts = {
			[1] = 1268782434,
			[3] = 1268782519,
		},

		Pets = {
			['Russo Pet'] = 100,
		},
	},
	
	['City Op'] = {
		Price = 2000,
		Area = 'Spawn',
		Robux = true,

		DevProducts = {
			[1] = 1268782669,
			[3] = 1268782702,
		},

		Pets = {
			['Galactic Overlord'] = 100,
		},
	},
}
2 Likes

Do you mean sorting by rarity in the UI that opens when you get close to the egg like this:


or do you mean sorting by rarity in the dictionary that the eggs are stored.

(If you meant the second one, I think it’s impossible to do but I will type how you can do the first one)

1 Like

image

Change the UIGridLayout’s SortOrder to LayoutOrder like this:
Ekran görüntüsü 2023-08-12 231653
And in your script (at the part which adds the pet gui), add a code that looks something like this:

PetGui.LayoutOrder = 0-Percentage
1 Like

thank you very much! it really helped

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.