GetAsync is not an instantaneous method and therefore yields the current thread until a result is fetched.
table.sort requires a callback function as its second argument to specify the sort. Callback functions should never contain code that yields.
What I would suggest you do is iterate through all players and cache their current ELO rating every few seconds (or better yet, once when they join and then again everytime their rating is updated). Store the cache in a table, and then fetch the value in the table because there is no yielding necessary for that.
Edit:
If you need to access all possible players... just use GetSortedAsync and iterate over all of the pages rather than using GetAsync... just because the players are not in the game doesn't change the fact that caching is the solution.
2 comments
This would work, however I need to be able to access all players who HAVE a ranking, so even if their not in the game.
You're overthinking this. Read my edit.