I'm using ContourPlot
to extract data points from a rather non-trivial curve in the $(x,y)$-plane. However, the points are spit out in the order of increasing $x$ value. This curve has many turning points, and I want to order the points in such a way that they correspond to a parameter moving along the length of the curve. I'm wondering if there's a way to reorder these data points in a compatible way for parameterizing with respect to length along the curve.
Since my code is messy and involves, maybe an example would be best.
data2 = Table[{x, Cos[x]}, {x, -2*Pi, 2*Pi, \[Pi]/16}] // N
dataa = RandomSample[data2]
ListPlot[dataa]
So here we have a small number of data points from a cosine curve, and I've placed the points in a random order. Can one reorder the points in a way that corresponds to moving smoothly from the left to the right along the curve? Clearly in this case, there's a trivial solution where you order the points from smallest to largest $x$ value. In my case, the curve is not a function of $x$, so this won't work! So maybe is there another way, other than this trivial solution? Thanks in advance.