Here is the problem:
I create a coordinate list as follows:
DegreeP = 5;
lst = DeleteDuplicates@
Select[Flatten[
Table[Permutations[{a, b}], {a, 0, DegreeP}, {b, 0, DegreeP}],
2], #[[1]] + #[[2]] <=DegreeP &];
By assigning the index of each coordinate, I can represent the order as a listplot
ListPlot[{lst, lst},
Joined -> {True, False}, PlotStyle -> {Orange, Black},
ImageSize -> Medium, PlotRangeClipping -> False, ImagePadding -> 20,
Epilog -> (n = 1; Text[Style[n++, 11], #, {-1, -1}] & /@ lst)]
The real order (solution) in which the coordinates should be found, however, is as follows
sol = {{0, 0}, {0, 1}, {1, 0}, {0, 2}, {2, 0}, {1, 1}, {0, 3}, {3, 0}, {1, 2}, {2, 1}, {0, 4},
{4, 0}, {2, 2}, {1, 3}, {3, 1}, {0, 5}, {5, 0}, {2, 3}, {3, 2}, {1, 4}, {4, 1}};
As a ListPlot
ListPlot[{sol, sol},
Joined -> {True, False}, PlotStyle -> {Orange, Black},
ImageSize -> Medium, PlotRangeClipping -> False, ImagePadding -> 20,
Epilog -> (n = 1; Text[Style[n++, 11], #, {-1, -1}] & /@ sol)]
I would like to find a way to sort my lst to get the same order as sol
For that, I tried with SortBy[] but I am unable to find the right pattern...
Any idea ?
*** UPDATE AFTER @kglr ANSWER***
DegreeP = 9;
lst = Join @@ Map[SortBy[{-Norm@# &}]@FrobeniusSolve[{1, 1}, #] &]@ Range[0, DegreeP];
ListPlot[{lst, lst}, Joined -> {True, False},
PlotStyle -> {Orange, Black}, ImageSize -> 600,
PlotRangeClipping -> False, ImagePadding -> 20,
Epilog -> (n = 1; Text[Style[n++, 11], #, {-1, -1}] & /@ lst)]
Let's print the result for DegreeP={8,9,10}, it seems that there is a "jump" in the pattern for DegreeP = 9. This case does not seem to occur anymore for 20>DegreeP>1.
Note :
- I am only interested in DegreeP<20
- I cannot manually change the position of the elements
DegreeP = 8
DegreeP = 9
DegreeP = 10