Sorting rules by a custom ordering function: order[a_Rule, b_Rule] := (a /. b) =!= a; expr = A^3 B^4/b + A^3 B^4 C X/d; rules = {A^3 B^4 -> Γ, X -> ρ, A^3 B^4 C -> Δ}; Sort[rules, order] > {A^3 B^4 C -> Δ, X -> ρ, A^3 B^4 -> Γ} expr /. rules > Γ/b + (C X Γ)/d expr /. Sort[rules, order] > Γ/b + (X Δ)/d