I often see on this site and at the mathgroup the repeated questions on how to rearrange expression that Mathematica "likes" to keep in one form, but the user prefers in another. Consider this trivial example:
(x^2 - 1)/(x + 1) // Simplify
Mathematica returns -1 + x
, rather than the x - 1
that the user might prefer.
I have seen many answers to these questions and gave a few myself. The problem here is that the answers are non-universal; they strongly depend upon the expression in question. Besides, they require some additional programming for sorting terms, and the more complex the formula, the longer will be the code that does the sorting.
It seems that the problem of sorting terms in analytic expressions into the desired order might be solved, if one could assign tags to the terms to be sorted. One would then sort the terms according to a specified list of such tags.
Now comes my question, can you tell me how to apply tags to expression terms?