```Date: Apr 17, 2013 2:30 AM
Author: David Park
Subject: Re: How to apply tags to expression terms?

Alexei,The answers you received recommending TraditionalForm are probably the wayto go in most cases. But suppose that one prefers to work in StandardForm,or for one reason or another TraditionalForm is also not the order you wantfor terms or factors? Then I think a convenience routine might be useful.I don't think the idea of using tags and trying to compute with suchexpressions is too great. One would have to almost rewrite Mathematicaalgebra! But we can write a useful routine for final display expressions.So here is a routine that allows you to reorder terms in a Plus expressionor factors in a Times expression.HoldOrderForm::usage =   "HoldOrderForm[permutation][expr] will reorder the terms or factors \of a Plus or Times expression according to the permutation and put \the result in a HoldForm.";SyntaxInformation[HoldOrderForm] = {"ArgumentsPattern" -> {_}};HoldOrderForm[permutation_?PermutationListQ][(f : Plus | Times)[    args__]] /; Length[{args}] == Length[permutation] := (HoldForm @@ {(List @@ f[args])[[permutation]]}) /. List -> f Then for your simple case:-1 + x;HoldOrderForm[{2, 1}]@% x - 1Here is a case where we first reorder terms and then reorder the resultingfactors:(1 - x + Exp[I x]) (x - 1)Inner[#1[#2] &, {HoldOrderForm[{2, 1, 3}], HoldOrderForm[{2, 1}]},  List @@ %, Times]HoldOrderForm[{2, 1}]@% (1 + E^(I x) - x) (-1 + x) (x - 1) (E^(I x) + 1 - x)(E^(I x) + 1 - x) (x - 1)If you like it I'll put it in Presentations. Presemtations contains a numberof convenience routines for manipulating expressions to special forms. Someof them just seemed useful to me but many of them came from questions onMathGroup. If the ideas seem useful and not too specialized then I considerincluding them. And they are in a common place where Presentations users canfind them.David Parkdjmpark@comcast.net http://home.comcast.net/~djmpark/index.html From: Alexei Boulbitch [mailto:Alexei.Boulbitch@iee.lu] Dear Community members,I often see on this site an at the StackExchange the repeating questions ofhow to rearrange some expression, that Mathematica "likes" to keep in oneform, but the user prefers another one. It is like in this trivial example:    (x^2 - 1)/(x + 1) // Simplifythat Mathematica returns -1+x, rather than x-1 that might be wished by theuser.I have seen many answers to this questions, and gave few mine. The problemhere is that the answers are non-universal: they strongly depend upon theexpression in question. Besides, they require some additional programming,and the more complex is the formula to sort, the longer will be the part ofthe sorting code. It seems that the problem of sorting terms of analytic expressions in thedesired order might be solved, if one could assign tags to the terms to besorted, and then sort the terms according to a specified list of such tags.Now comes my question, do you know how to apply tags to expression terms?I have seen an analogous functionality in the Presentation Master, thepackage of  David Park. There, however, the tags are used to be assigned tosub expressions, the held part of the expression in question. David, is itpossible to assign tags to expressions that are not held?Thank you in advance.AlexeiAlexei BOULBITCH, Dr., habil.IEE S.A.ZAE Weiergewan,11, rue Edmond Reuter,L-5326 Contern, LUXEMBOURGOffice phone :  +352-2454-2566Office fax:       +352-2454-3566mobile phone:  +49 151 52 40 66 44e-mail: alexei.boulbitch@iee.lu
```