Is there a standard name for the following algorithm? At each step, the code picks an index, remove the object at that index, and remember to never pick that index again. See the following illustration:
Others have suggested the Fisher–Yates shuffle, but it seems like this algorithm is simpler. I found this algorithm useful for many different types of problems. An example use case is, to cycle through 24 hours in a day, by random, without picking the same hour twice.
An index is used to avoid picking the same object twice,
mapping(uint => uint) shufflingIndex;
a counter is used to shrink the list of objects to choose from
and a random number generator is used to select an object.