/// Factors are first sorted by category. Then within each category, references are placed before
/// + Having a canonical ordering here is helpful in identifying weighted sums: 2x + 3y + 4d + ....
/// means that we do not have to reorder the product again once those references get evaluated to