I used Mathematica to greatly simplify an algebraic expression. I now want to copy it into some notes, but it by defaults things in a very non-intuitive manner. I have a sorting function that will sort the expression properly, but the output still reverts to Mathematica's default sorting algorithm.
As an example, let's say I want it to output: f[b] f[a]. The sorting function
In[1]:= sorted = Sort[Level[f[b] f[a], 1], OrderedQ[{(#2)[[1]], (#1)[[1]]}] &]
Out[1]= {f[b], f[a]}
properly returns a sorted list. But when I then apply the Times function to bring it back to an algebraic expression, it goes back to the default way of sorting:
In[2]:= Apply[Times, sorted]
Out[2]= f[a] f[b]
Is there a trick for formatting the output of an expression to match the ordering I would like? Preferably something I can can both view directly in Mathematica as well as copy to LaTeX.