Avoid same type of item twice in a row in loop
I have a bunch of items in my loop that belong to the same type. I want everything in the experiment to be randomized, but ideally, I would like to avoid that participants see the same type of item twice in a row.
To illustrate, here is an example; I have 9 items of 3 different types:
*breed* *animal* poodle dog corgi dog malinois dog siamese cat persian cat bengal cat arabian horse appaloosa horse mustang horse
At the moment, everything from this list is selected completely at random. Therefore, it can happen that for example two "cat" items are shown after each other (e.g. siamese comes directly after persian). If possible I'd like to avoid this, so that it will never happen that two cat (or dog or horse) items are shown one after another. So a valid order would be for example: poodle, siamese, mustang, persian, malinois, arabian, etc..
Is this possible, and if so, how?