After I answered this question , I consulted with several colleagues who agreed that the best and typical way to solve this problem is:
f[{a_, b_}] := f[{Sort[a], Sort[b]}] /; Not[OrderedQ[a]] || Not[OrderedQ[b]] In[99]:= f[{{1, 2, 3}, {5, 4, 3}}] Out[99]= f[{{1, 2, 3}, {3, 4, 5}}]
Alternatively, you can replace the internal List heads with a custom head symbol that has the Orderless attribute, and if formatting really matters, you can use various formatting methods that were recently discussed here =)
Michael pilat
source share