I can't believe that there is no built in way in Mathematica to do
this right.
It's possible to convert forth and back to character code, but then there is the problem, that the order of lists is undefined
In[32]:= {40, 43, 51, 107, 45, 49, 44, 45, 52, 110, 47, 51, 45, 51,
109, 43, 107, 45, 55, 47, 51, 41} > {40, 43, 51, 107, 43, 49, 44,
45, 110, 45, 109, 43, 107, 41}
Out[32]= {40, 43, 51, 107, 45, 49, 44, 45, 52, 110, 47, 51, 45, 51,
109, 43, 107, 45, 55, 47, 51, 41} > {40, 43, 51, 107, 43, 49, 44,
45, 110, 45, 109, 43, 107, 41}
so let's do something simple minded
In[36]:= Clear[weitzerOrder]
weitzerOrder[l1_List?VectorQ, l2_List?VectorQ] :=
Block[{o = 1, len1 = Length[l1], len2 = Length[l2]},
While[l1[[o]] == l2[[o]] && o <= Min[len1, len2], o++];
If[l1[[o]] < l2[[o]],
True, (* else *)
If[o > len1,
True, (* else *)
False
]
]
]
FromCharacterCode /@
Sort[ToCharacterCode /@ {"(+3k-1,-4n/3-3m+k-7/3)", "(+3k+1,-n-m+k)", "(+3k-1,-n-m+k-1)"}, weitzerOrder[#1, #2] &]
Out[38]= {"(+3k+1,-n-m+k)", "(+3k-1,-4n/3-3m+k-7/3)", "(+3k-1,-n-m+k-1)"}