Simple question: Reordering / Referencing Lists

Hello,

Really simple question here, I’m getting back into GH after a short break and can’t remember how to reorder / reference one list against another.

As in the picture, I have reordered my “points unordered” list to match up to the curve they are nearest to. Each of these points shared an index with a correlating list of values in “Points Values Unordered”. How do I now reorder that list so that I can then apply each value to its nearest curve?

Any help / advice would be very much appreciated.

LC Upload.gh (3.5 MB)

Looking closer I realise I’ve completely misunderstood what the nearest point is doing here.

I’ve taken a step back and realised what Im trying to do is harder than I thought.

How can I re-order my points and values to correlate with the nearest line / contour?
[At present the wrong contours are being moved]

image

image

Simple.gh (3.5 MB)

Is this what you are after?


LC Upload_re.gh (3.5 MB)

Hi Kim,

Thanks very much for that, it seems to have done the job at this scale. Now that I have to scale this up to nearly 2000 lines and contours I’ve plugged it in and left it running. As it has to reference each point against each line to find the closest, I imagine it will take quite a while.

If I just let it do its thing, is waiting the best option here or is there a better way to deal with large datasets?

If you don’t mind to use plugins, Peacock has a user object namedClosest Geometry and probably it will take less time than my previous posting, but not sure it can save how much time for your case…


If you want much faster solution, then you’ll probably need C# scripting…

Responding to a >6 year old topic for the sake of whoever googles this next.

You can make this work at scale quickly by using the Closest Point (CP) component and using the output indices + list item to sort this. The key is to represent the unsorted geometry as a point, get the index of the closest point, and then sort the original geometry list with the indices from the closest point component.

^In this screenshot, I’m matching 3216 surfaces to their offset and shuffled counterparts. It only took ~500ms to use the list item index method.

For those not familiar with this workflow, you can use list item with a list of indices to sort and match lists. This also works to match an unsorted list into a tree if your sorted data is branched. This will do the same thing as match tree or unflatten, but won’t break if the number of input data items in each list is different. Try it out!