user7755452
user7755452

Reputation:

order based on two nodes in neo4j

In neo4j i want to order the results based on ContactId and LookedupStatus in descending order.

This query orders the results based on ContactId only

   MATCH (p:Contact)<-[:RELATIONSHIP]-(d:GroupMember) 
   WHERE toint(d.GroupId) = 55 
   and p.EmailId<>''
   RETURN p
   order by toint(p.ContactId) desc

How to modify the above query so that it orders on both p.ContactId and p.LookedupStatus

Upvotes: 0

Views: 151

Answers (1)

stdob--
stdob--

Reputation: 29172

You can combine the sort conditions:

UNWIND [ {a:3, b:2, c: 1}, {a:1, b:2, c: 2}, 
         {a:1, b:1, c: 3}, {a:3, b:1, c: 4} ] as n
RETURN n ORDER BY n.a DESC, 
                  n.b ASC

Upvotes: 3

Related Questions