How Do Ordered Data Stores Sort Entries of the Same Value?

I feel like this is a very basic question but I can’t find anything about it.

If I make an ordered data store and add multiple entries of the same value, which would come as the first result on the returned data store pages object?

For example,
Jimmy = 0
Johnny = 0
Jamie = 0

If I call GetSortedAsync, who will come out on top? Does it sort alphabetically, by date added, or something else? Thanks.

1 Like

It sorts by the time added, if you add a value at second 0 then add another value at second 1, the value added on second 1 will be the last one and the value on second 0 will be the first.

Judging by what you’re asking, it seems like you’re making a table. So its sorted by time added.

Calling GetSortedAsync will return the last value.

So I want to give the user a way to sort by date added. My original plan was to set the value to tick() and use that for sorting but would it be more efficient to just set the value of each entry to 0 and let the system sort for me?

Oh sorry, I didn’t clarify.

Sorting by time means sorting by date, so you should be fine using the system’s sorting style.

I tried what was discussed in this thread and it did not work. The system does not seem to sort by the time posted when they are all set to 0. However, It also does not seem to sort alphabetically. One thing that I have noticed is that it seems to consistently return the same order. I will just use the tick() system that I mentioned from now on. I will mark this as the answer for now but I will leave it open for future corrections.

Thats fine. Glad you found a more permanent solution.

Careful how you use DataStores.