cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

IN operator and result ordering

Hi all,

in a use-case we'd like to provide a parameter as an array which is used with the IN operator:

MATCH
  (p:Person)
WHERE
  p.name in ["foo","bar"]
RETURN
  p

Can we rely on the Person nodes being returned in the order as given by the values in the array, i.e. first all persons with the name "foo", then those with the name "bar"?

Cheers

Dirk

2 REPLIES 2

ameyasoft
Graph Maven
Try this:

MATCH
  (p:Person)
WHERE
  p.name in ["foo","bar"]
WITH p order by p.name ASC
RETURN
  p

My question goes into a different direction:

The array parameter already provides an arbitrary order which cannot be expressed by an order by (e.g. defined by a user). The intention of the query is to fetch more data (e.g. attributes/relations) of the Person keeping the provided order.

Cheers

Dirk