title: Neo4j - sort nodes by their connection in a procedure
body: <p>There are a number of point nodes that are interconnected. Then there is a parent node, the element node, which contains some of these point nodes, or better expressed, which has a relationship to some of them.
  (p1:Point)-[:leadsTo]-&gt;(p2:Point)-[:leadsTo]-&gt;(p3:Point)...
  (e:Element)-[:contains]-&gt;(p2), (e)-[:contains]-&gt;(p3)</p>
  <p>In a procedure I pass the element and get there all the
  nodes, which I get via the relation &quot;:contains&quot;.</p>
  <pre><code>    val relationships = node.getRelationships(RelationshipType.withName(&quot;contains&quot;))
      return  Stream.of(Output(relationships?.map { it.endNode }?.map { pointNode -&gt;
  </code></pre>
  <p>Now I would like to have these nodes sorted by their connection among each other. So [p2,p3]</p>
  <p>Is there a way to do this?</p>