Grouping and sorting lists

I have a list of co-ordinates that I need to group, then sort within each group. I have an associated list of integers which indicates the group each co-ordinate is to be assigned to and another list of real numbers whose ascending values indicate the sorted order.

I can use a path mapper to split each list and then sort, as illustrated here:


HowToGroupAndSort.gh (25.2 KB)

But this only works if the groups are all the same size and that size is known in advance. In a full implementation that will not be the case so I need another way to do this. I would rather avoid writing code to create a solution if I can.

Any suggestions as to a better approach would be most welcome, preferably without using third-party plugins.

TIA
Jeremy

maybe something like this?


HowToGroupAndSort_Re.gh (21.2 KB)

[edit] maybe adding another sort list here is the better practice, just in case the integers are not already sorted


HowToGroupAndSort_ReRe.gh (20.5 KB)

2 Likes

Hi @inno,

Thank you for Member Index, one I’ll memorise for future use.

I appreciate your speedy response and nice solution.

Regards
Jeremy

1 Like

Perhaps a bit late, but here’s an alternate solution to group and sort your points by their positions.

HowToGroupAndSort_re_kr.gh (28.8 KB)

Still uses the Create Set Member Index List Item pattern that @inno showed to do the initial grouping of the points.

Points are grouped by angle measured from the World XY plane then sorted by distance from origin. Then some DataTree manipulation to get the points arranged into groups that form the spiral shapes.

Data in the panels at the end is created from the grouped and sorted points. The “Sequence” panel is calculated by distance from origin re-mapped to a 0-1 domain. It differs from the data you provided beyond the 3rd decimal place.

-Kevin

1 Like

Hi Kevin,

Thank you for putting time and effort into this. However at first glance it looks more complicated than Inno’s so I’ll be sticking with his in the production model.

I shall put time and effort into understanding your approach, so I thank you for another learning opportunity.

Regards
Jeremy

Yes, the file I posted is made to work with the data you provided - likely to need modification if the input data changes.

I did it as an exercise in DataTree management - an interesting puzzle.

-Kevin

As @kev.r has demonstrated :clap:, the data comes from points on spirals: in detail, from the intersections of polar arrays of clockwise and anticlockwise spirals.

I was exploring solutions for a a parametric way to generate stylized frames around quadrilateral spaces arranged in such a fashion, in response to another person’s post on discourse. They’ve subsequently deleted their post, possibly because they came up with their own solution.

Rather than waste the work I’ve done (or @inno 's) I’ll post the outcome here so you can see what you’ve contributed to:


PDRF.gh (41.2 KB)

Regards
Jeremy

1 Like

Hi @jeremy5
There are other ways to find intersections like using curve | curve intersection

And to group and sort points with collision or curve closest point

PDRF2.gh (33.9 KB)