Ordered DataStore not ordered

So im learning abt ordereddatastore but when im testing it, it doesnt return the entries in order.

this is what i got right now:

local DSS = game:GetService("DataStoreService")

local TotalToys: OrderedDataStore = DSS:GetOrderedDataStore("TotalToys")

local TotalToysLeaderboard = workspace.TotalToysLeaderboard

TotalToys:SetAsync("Jack", 10)
TotalToys:SetAsync("Sam", 15)
TotalToys:SetAsync("Alex", 20)
TotalToys:SetAsync("Jerome", 50)
TotalToys:SetAsync("Tylil", 340)
TotalToys:SetAsync("Jason", 0)

local pages = TotalToys:GetSortedAsync(true, 100, 1)

local entries: Pages = pages:GetCurrentPage()


for rank, entry in pairs(entries) do
	print(rank.." - "..entry.key..": "..entry.value)
end

and this is getting printed:
image

im just getting the order of when i set them. What am i doing wrong?

It’s ordering the result in ascending order, try setting it to false.

1 Like

ohhhh damn i put the wrong boolean. Thanks

1 Like

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