expr = g[x3, x2, x1];
You must use RuleDelayed (:>
) instead of Rule
g[x3, x2, x1]expr /. g[arg___] :> g[Sequence @@ Reverse[{arg}]]
g[x1, x2, x3]
Many other possibilities include
Cases
with {0}
level
First @ Cases[g[x3, x2, x1]Cases[expr, h_[args__] :> h[Reverse[{args}]], {0}]
g[{x1, x2, x3}]
Position
and Part
or Query
p = Reverse @ Flatten @ Position[g[x3, x2, x1]Position[expr, _Symbol, Heads -> False]
{3, 2, 1}
g[x3,expr[[p]]
g[x1, x2, x3]
Query[p] x2,@ x1][[p]]expr
{3 g[x1, 2x2, 1}x3]