How do ordered datastores work when the values are the same?


Simple question, when 2 ordereddatastore values are the same, when calling :GetOrderedAsync, how does it calculate which value is higher and which is lower? Is it based on the time it was updated?

Player1’s value is 10, they got it on January 1st 2020
Player2’s value is 10 but they got it on January 1st 2021

Is Player1’s rank considered higher because they got it first?

Considering nothing in coding is random and I don’t believe there is any available documentation on this, I would assume that it would be either the time it was saved or it might be sorted by the key its saved to, you could experiment and try to figure it out :flushed:

1 Like

I don’t think they’re sorted by date, but instead, the player’s number (from userID) - in an order. Here’s an example:
ID: value
2: 100 - got it first.
3: 100 - got it second.
1: 100 - got it last.
in OrderedDataStore, it’d be seen as:
1: 100
2: 100
3: 100
If you’re wanting to sort from date, I’d consider using DataStore that not only saves their value but also their os.time() from getting it - then use that for comparing the other player’s timestamp and see which one is lower (older).

1 Like