Question: how to sort operators

restart; with(Physics); Setup(mathematicalnotation = true):

am := Annihilation(N); ap := Creation(N)

Setup(op = {b[1], b[2], b[3]})

alg := seq(%Commutator(ap, b[i]) = 0, i = 1 .. 3), seq(%Commutator(am, b[i]) = 0, i = 1 .. 3), %Commutator(b[1], b[2]) = b[3], %Commutator(b[1], b[3]) = -Physics[`*`](2, b[1]), %Commutator(b[2], b[3]) = Physics[`*`](2, b[2])

q := %Commutator(Physics[`.`](ap+am, b[2]), b[1])

p := expand(q)

ans := sort(p, [a, b])

ans := Physics[`*`](Physics[`*`](`a+`, b[2]), b[1])+Physics[`*`](Physics[`*`](`a-`, b[2]), b[1])-Physics[`*`](Physics[`*`](b[1], `a+`), b[2])-Physics[`*`](Physics[`*`](b[1], `a-`), b[2])

in the ans ,there lies terms like 

                b[1].ap.b[2]

because i define [b[1],ap]_=0,the term can be written as

              ap.b[1].b[2]

yet ,the command sort can't work well in physics basis.

How do i solve this problem. 

 

Please Wait...