How to sort cordinates?

Given your description of what you are trying to do, I’m now wondering if this is less about sorting indices and more about finding and creating the lines from a set of random points?

My spontaneous approach is to start off with the first point in that list and then iterate against all other points and – checking against a max. distance cutoff – finding the closest one, and then using this new point again finding the the next closest one in the list, rinse and repeat. If no other points are found within that max. distance cutoff, then all collected points up to this moment are considered a line.

After you have found these lines, the initial indices of the individual points seem useless? Unless I’m still misunderstanding what you are trying to do?

Read more here: Source link