Minecraft – How to execute a command at an random entity

minecraft-commandsminecraft-java-edition

im creating a rpg map and im going to use armor stands to randomly generate the dungeon rooms, but as i noticed, you cannot use this command:

execute at @r[type=armor_stand] run ...

I have no idea how to pick a truly random armor stand with any other method.
can anyone help me please?

My game version is 1.15.2

Best Answer

Just found out that there is a selector for sorting randomly :

execute at @e[type=armor_stand,sort=random,limit=1]

this executes a command at a random armor stand 1 at a time.