Sort nodes with apoc.coll.sortNodes multiple properties


(Sandip) #1
  • neo4j 3.4.8
    Hi,

I'm using <apoc.coll.sortNodes(collect(i),'event_date') as elems> to sort my nodes but I want to sort on multiple properties like event_date and priority. Is it possible with apoc.coll.sortNodes?

Regards,
Sandip


(Andrew Bowman) #2

You'll want to use apoc.coll.sortMulti(), however this will use the node properties maps rather than the nodes themselves, so you won't be able to do additional things with the items in the collection that you could normally do with nodes (match from them, use them in pattern expressions, get their graph id, visualize results in the graphical view). There is a workaround you can use to get around that if needed.


(Sandip) #3

Thanks Andrew, this solved my problem.

Regards,
Sandip