You said at the gym, so I will start with gym etiquette.
Don't reserve multiple stations, dumbbell, etc... So in the scenario, unless you use the same machine or dumbbells, the best way to organize your set is to use only one piece of equipment at a time and do whatever you want with it.
Now that basic gym etiquette is out of the way.
There are really two main trains of thought when it comes to "GAINZ". The first one is to trickle down from compound to isolation and the second is to start with the muscle group you want to prioritize first.
If you're doing back/biceps today, in the first case you will start with your back exercise. The reason is that you use your biceps in the majority of your back work outs. Later, once you get to your bicep workout, they have already have a workout. Sure, it will be lighter, but you're doing more volume. If you were to start with your biceps, your back exercise would suffer.
Now, if you work out shoulders and chest on the same day. Say you want a bigger chest, you would start off your day with the bench press. This will allow you to put on more weight or do more volume on the bench, rather than say overhead press. If you want bigger shoulders, start with overhead press for the same reason. The reasoning behind this method is that you have more energy to devote on a body part at the beginning of a workout as opposed to the tail end of one. It is pretty self explanatory.
Another method you can use is just alternate between body parts. From what I've gathered, people tend to take this approach when they have a primary movement and finishers. You would start with bench, then do overhead press, then triceps. Move onto flies, shrugs and then more triceps, etc...
There's no wrong order to do exercises. Some people do supersets, others take long breaks between exercises. It depends on your goals, if you need the break before repeating a muscle group, do it. If you need StackExchange to find the answer to this question, you are probably not at the point where you will benefit from this type of optimization.