Question: Sort non-commutative variables with(Physics)


I'd like to sort variables which are non-commutative and obey certain commuting rules in a preferred order. Here is a minimal example


Setup(mathematicalnotation = true):Setup(noncommutativeprefix = {q, w}, algebrarule = {%Commutator(q, w) = A})

If I want to rewrite q*w as A+w*q since I prefer the order w>q, what should I do? I tried sort(Simplify(q*w, algebrarules), [w, q]) but it doesn't work.

Thank you in advance.

Please Wait...