The Sort
function will by default sort from lowest to highest.
In[1]:= Sort[{3, 1, 4}]
Out[1]= {1, 3, 4}
However, if the list contains non-numerical values, it will sort it incorrectly
In[2]:= zeroes = {2 Pi - 2 ArcTan[Sqrt[2 + Sqrt[5]]],
2 ArcTan[Sqrt[2 + Sqrt[5]]], 2 Pi + 2 ArcTan[Sqrt[2 + Sqrt[5]]]};
In[3]:= zeroes // N
Out[3]= {4.04615, 2.23704, 8.52022}
In[4]:= Sort[zeroes] // N
Out[4]= {4.04615, 2.23704, 8.52022}
One could use the Greater
function as a parameter to Sort and then reverse the input
In[5]:= Reverse@Sort[zeroes, Greater] // N
Out[5]= {2.23704, 4.04615, 8.52022}
There is no Lesser
function in Mathematica, but there must be a better way to do this, without converting the data to floats.
Less
on expressions, they're evaluated to numeric where possible. $\endgroup$