How can I sort curves by midpoint distance to closest point on curve?

Hi all,

Can someone please help me with how to write a definition for the following scenario?

I am trying to sort a list of curves (entwined) by the distance of their midpoints and the closest point on a curve. So far I have the curve midpoints and the closest points on the reference curve, but I can’t figure out how to sort the curve list based on these?

See below for a simple sketch

The ‘TT Toolbox - Sort Curves along Crv’ is not available for Mac which I am running Rhino on which does this whole thing automatically.

Thanks,

this might be a way

Thanks @markz. I’ll give this a try when I get home and let you know if it works!

Edit: thanks for the solution