# Sort grouped list by one value

Hey,

i try to sort out a list where i packed vectors and the angle they belong to, together in a list. Now i try to sort the list by the angle, so at the first value at each listmember small to large.
I i need them values sticking together all the way so i can extract the vector after to cull the ones i dont need based on their angle.
Somehow the sort list function doesnt work here.
See the different outs in the green brackets.

I need it that way because in the beginning the angles and vectores are allways different. In the End i have to tell the function for example, cull 0,1,2 and it has to be allways right. so i cant just kill the specific ones after the bang box.

Dont know if my way to start is the right one, but if there is a way to do it like that it would be awesome if you could help me there.

any help?

Sort component sorts keys as numbers (ints, doubles) you are giving it vectors. You can’t sort vectors like that. You have to know how you want to sort them. You needs keys which should be your angles (degrees or radians) and then put the actual vectors into the A input.

Hey,

thanks, but how can i keep them together?
i could sort them out individually way before that in the picture, but i need them sticking together like that. Thats very important because the vectors and their angles will change when it gets looped and i dont know any other way to break it down so i can delete allways the smalest angles.

Is there a way to sort the list based on the first values in the line of whatever stands there? That would be the angle and thats a value or a key?
So the vector is just a ad on to the value and doesnt effect the sorting process?

Bdw i could also use the radians instead of the angle if that helps. I have the sorce for both…
Its just that my understanding of math isnt that amazing so i just used the angle in degree.

use list item with index 0 and index 1 to create two separate lists (one of angles and one of vectors) with corresponding indices. then use sort list with the angles as keys and vectors as values.

took a bit to sort out the file so you dont have to manage the massive tree…
Does it work like that?vector_angle.gh (16.0 KB)

Hey,

i tried it, but that doesnt work? or am i doing something wrong?
the keys get all sorted, the angles are now in the right order, but the vectores dont fit anymore to the right angle?

well, you gotta plug em in to the same sort component
just plug that output of list item with index 1 into the A input of the top sort component. should work.

Legend! That works!
Thanks!