I wish to sort the below list upon the first elements:
{{1/2 (-1 - Sqrt[2]), {{1, 11}, {1, 12}, {2, 11}}},
{-1 - Sqrt[2], {{5, 11}, {5, 12}}},
{1/2 (1 - Sqrt[2]), {{1, 9}, {1, 10}}},
{1 - Sqrt[2], {{7, 9}, {7, 10}}},
{1/2 (-1 + Sqrt[2]), {{1, 7}, {1, 8}}}}
The desired output can be shaped as:
{{-2.414, {{5, 11}, {5, 12}}},
{-1.207, {{1, 11}, {1, 12},{2,11}}},
{-0.414, {{7, 9}, {7, 10}}},
{-0.207, {{1, 9}, {1,10}}},
{0.207, {{1, 7}, {1, 8}}}}
where the first elements are numeric values (without Sqrt
symbols) and just for 3-digit
precision.
I have tried with N
function. But the problem gives rise the effects on any pairs for example output be shaped as {-2.41421, {{5., 11.}, {5., 12.}}}
(with a dot after 5
or 11
.
Another problem is related to sorting of list just based on the first elements and NOT other elements.
SortBy[lst, First[N[#]]&]
$\endgroup$