# Metropolis Sampling sample order

I am new to Metropolis sampling, here is a question that confuses me. Assume that there are two sets of variables $$a$$ and $$b$$ we want to sample. Let $$X$$ denote the observations and $$p(X|a,b)$$ denote the likelihood. $$T$$ is the max iterations. Which of the followings are correct?

Option 1:

for t in 1...T:
new_a = ... //propose new variables a
p = min(1,p(X|new_a,b)/p(X|a,b))
thresh  = ... //a random number generated from a uniform [0,1]
if thresh < p:
a = new_a //accept new_a
new_b = ... //propose new variables b
p = min(1,p(X|a,new_b)/p(X|a,b))
thresh  = ... //a random number generated from a uniform [0,1]
if thresh < p:
b = new_b //accept new_b


Option 2:

for t in 1...T:
new_a = ... //propose new variables a
new_b = ... //propose new variables b
p = min(1,p(X|new_a,new_b)/p(X|a,b))
thresh  = ... //a random number generated from a uniform [0,1]
if thresh < p:
a = new_a, b = new_b //accept both a and b


Essentially, option 1 samples $$a$$ and $$b$$ separately. In each iteration, it samples $$a$$ first, then it uses the value of $$a$$ (either accepted new value or the old value) to sample $$b$$. Option 2 samples $$a$$ and $$b$$ together, they are either both accepted or rejected.

Simulating both components $$a$$ and $$b$$ from the prior at the same time and accepting with probability $$1 \wedge \dfrac{p(X\mid a^\text{new},b^\text{new})}{p(X\mid a,b)}$$ is a regular (and valid) format of the Metropolis-Hastings algorithm.
Simulating each component $$a$$ and $$b$$ sequentially from the conditional priors $$\pi(a|b)$$ and $$\pi(b|a)$$ and accepting with probabilities $$1 \wedge \dfrac{p(X\mid a^\text{new},b)}{p(X\mid a,b)} \quad\text{and}\quad 1 \wedge \dfrac{p(X\mid a,b^\text{new})}{p(X\mid a,b)}$$ is a (valid) form of the Metropolis-Hastings-within-Gibbs algorithm.