Check Minecraft Java scoreboard Leaderboards

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.
Pictures about "Check Minecraft Java scoreboard Leaderboards"



How do you see your leaderboard in Minecraft?
Via the /scoreboard objectives setdisplay command (see command reference), players' scores in specific objectives can be displayed in certain 'slots' in-game.How do you use scoreboards?
Scoreboard CommandMinecraft Scoreboard Command Tutorial [1.18]
Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.
Images: Andrea Piacquadio, Alexander Suhorucov, Alexander Suhorucov, Alexander Suhorucov