How do I order an array full of dictionaries?

Alright, I know this has been asked before but for some reason, this array full of dictionaries WILL NOT SORT!!!

Here is my code, and I will break it down a bit:

The code where I insert all the players into the array:

function insertStats(Table,playerName,value)
	local insert = {Kills = value, Player = playerName}
	
	players[#players+1] = insert
end

This function does work! It inserts the player’s stats into the array in the form of a nice little dictionary.

The code for sorting the array:

function Sorter(a,b)
	print(a.Kills.." "..b.Kills)
	return a.Kills > b.Kills
end

function sortTable(Table)
	table.sort(Table,Sorter)
end

This is the code that doesn’t work. It just… doesn’t sort the array for some reason.

This is my output window when printing what the table looks like:
image
Looks good so far, lets see what is inside the {…} for [1]. I would expect it to be a test dummy who has 999 kills.
image
Odd. Why am I in first place if I have 0 kills?

Im still stumped about why I can’t sort the array, Ive seen many examples and it works for other people… I thought my Sorter() function would sort the array based on the kills.

Pasted your code into a script and it worked fine for me. Are you sure you called sortTable before printing it out?

Ah silly me. I just realised I was adding the test dummy into the array AFTER sorting the table. I’ll move it infront of the sortTable function and see if that fixes it.

I don’t want players with the highest kills to be at the bottom though… wouldn’t that cause the player with the highest kills to be at the bottom?