For various purposes, I need a way to check scoreboard objectives rather than just checking a player's scores. Is there a command I can run that can find the largest score in a scoreboard and who has it? What about the smallest? What about the 8th largest? Is there a way I can get a list of all "players" with a score of 12 in a specific objective?
This functionality feels like it should exist in minecraft; you can display leaderboards on the sidebar, for example, but I can't find a way to access them with commands. Are any of these things possible? If so, how?
Edits for clarity: I need to be able to target offline players, not just a group of online players with various scores. That is, I want to create the same functionality as the sidebar leaderboard but accessible via commands. The sidebar leaderboard displays who has the highest score in an objective, even if it's a dummy player or armorstand or something, but it only lists the top 5. Additionally, and partially related, I want to know of it's possible to create a list of all players, online, offline, or dummy, with a score of 5, or any specific number.
This is a similar question, however, my question wants to be able to get the score of offline players or players that don't even exist. The solutions that exist target @a or @e and systematically check if their scores are higher. @a and @e don't target offline players, however, and can't identify the true highest score the same way a scorebore sidebar leaderboard can.