title: Neo4j - Using Skip and limit with path and ordering the returned nodes
body: <p>I am using Neo4j (version 3.5.1) and Spring-data-neo4j (5.0.10.RELEASE) in my application. I am also using OGM.</p>
  
  <p>I have the below relationship between my nodes:</p>
  
  <p><a href="https://i.stack.imgur.com/BDBmE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BDBmE.png" alt="enter image description here"></a>
  A vehicle (V) has Part(s) (P1, P2 and P3). Parts can themselves be linked with other parts (for e.g P2 is linked with P6)</p>
  
  <p>I am trying to write a cypher query to get all the parts in a vehicle. However, I want to paginate the results and also want to order the parts ordered by the creation date (part created recently is returned first)</p>
  
  <p>Below is my query:</p>
  
  <pre><code>MATCH (vehicle: Vehicle{id:{vehicleId}})
  WITH vehicle MATCH p=(vehicle)-[:HAS_PART]-(part:Part)
  WITH p, part SKIP 1 LIMIT 1 OPTIONAL MATCH m=(part)-[:IS_LINKED_WITH]-&gt;(:Part)
  RETURN collect(nodes(p)), collect(relationships(p)), collect(nodes(m)), collect(relationships(m))
  </code></pre>
  
  <p>I sometimes get result size greater than 1. Also I am not sure how to order the returned Part by creation date (Part node has creationDate property set when it is created).</p>
  
  <p>Any help would be highly appreciated. Thanks.</p>
  
  <p>Data can be create as follows:</p>
  
  <pre><code>merge (v:Vehicle{id:'V1'})-[:HAS_PART]-&gt;(p:Part{id:'P1'})-[:IS_LINKED_WITH]-&gt;(p:Part{id:'P5'})
  
  match (v :Vehicle{id:'V1'})
  merge (v)-[:HAS_PART]-&gt;(p:Part{id:'P3'})
  
  match (v :Vehicle{id:'V1'})
  merge (v)-[:HAS_PART]-&gt;(p:Part{id:'P2'})-[:IS_LINKED_WITH]-&gt;(p:Part{id:'P6'})
  </code></pre>