Point and Line Association

I recieved a csv file that lists the point coordinates and their indexes, and another that lists start/endpoints that create lines. I constructed a wireframe from this data.

I want to organize these lines generated by their respective point indices. So all of the lines that start and end at point 1 are grouped into their own tree branch. I tried using Cset on the start and end points individually but the indices do not line up when merged together.

I would have double the amount of lines at the end of the merge, and I would like to sort these lines according to their direction from the accosiated point (± xyz axis).

Thank you for your help.Wireframe Generatorhelp.gh (77.7 KB)