For example:
{a,b}::SortOrder.
{A,B}::NonCommuting.
ex:=A B (a-b)+B A (b-a);
import cdb.core.manip as manip
zoom(_,$B A A??$);
distribute(_);
manip.multiply_through(_,$-1$);
factor_out(_,$A,B$);
manip.multiply_through(_,$-1$);
sort_sum(_);
unzoom(_);
factor_out(_,$a-b$);