N:m relations between nodes

Dear Community

I’m managing n:m relations between nodes with two references - one at each node. This was very easy to setup and works, but is a quiet unclean solution.

Right now I think about on how to realize a real n:m searchable relationship with multiple (manual) sort-keys (at the relation itself).
I want to create a PHP type and use this in the Nodes’ type definitions. Of course it needs to necessary to use this relation via FlowQuery and to sort it. Does anyone of you have an example of such a setup or a tutorial? Or is there a better way?

Best regards,
Jan