Sorting by Geometry

When I sort curves for example, am I actually sorting by GUID?

I think length. (If I understand you right)

Actually Tim, I meant with geometries as the optional list of values, not the key. I should have been more specific.

When I sort curves for example, am I actually sorting by GUID?

Do you something specific in mind? Are you looking to replace the curve?

Sort By Curve is probably vector, if you flip it, as goes your sort.

Sort by Points X,Y,Z

The sort component you are using is using any numeric value.

There is also a Sort by Text if need be.

I doubt this works the way you want as [K] and [A] collections must typically be identical for synchronous sorting to work. In this case your keys are a tree, and your values are a list.

Sorting synchronously just means that the data inside the [A] collection is kept synchronised with the numbers inside the [K] collection. For example if you want to sort a list of text based on number of characters (from shortest to longest) you must first create the sorting keys.

What you have:
{ "This", "is", "how", "sorting", "works" }

You create a list of lengths for each text fragment:
{ 4, 2, 3, 7, 5 }

Then you sort the numbers from small to large, giving you:
{ 2, 3, 4, 5, 7 }

But this is useless, since what you wanted was to sort your text fragments from shortest to longest, not their lengths from smallest to largest. Hence you put your text into the [A] input and it will be also modified in the exact same way, yielding:
{ "is", "how", "This", "works", "sorting" }

David, the problem is it does work! I was looking at something I wrote a couple of years ago, it worked and I never really questioned why. Now, upon further examination, I realize I didn’t understand how it was doing what it does.

nearestcurve.gh (13.9 KB)

Interesting definition.

The first Sort is duplicating the 3 curves, by distance, so the 1st List Item gives the Closest Curve of the 3. The second Sort converted said Curve to a Length Value, which groups your incoming points by the 3 Curve lengths. The CSet is dispatching for you by that grouping.

Thank you; I seem to have known more two years ago than I do now… Which still brings me back to my original question: Is the first sort using the curve’s GUID to keep track?

I just don‘t get it clearly. (Not your problem, just my language skills :smiley: ) but one more try:
I think the index is sorted compared to your key value’s index. As long as you just work on lists, sort, list item etc, the guid will be the same of the curves.

Here are a couple different ways to get the branching at the end. If i get some time today i will try and do a different curve sort or two.

1 Like

Always good to see how things can be done only using native components - in case you’re on a desert island and just have Grasshopper.