You simply can’t do this directly with DataStore2. It’s easier to create a separate OrderedDataStore and just save the value there whenever DataStore2 updates.
You can use the AfterSave method on your DataStore2 object to save the respective data to the player:
local store = DataStore2("Data", player)
store:AfterSave(function(newData)
repeat
local s = pcall(orderedStore.SetAsync, orderedStore, player.UserId, newData)
until s
end)
With this in place, you can just use GetSortedAsync on orderedStore to get the leaderboard you need.