Sort factors of variable expressions