apoc.coll.containsAllSorted

Function

apoc.coll.containsAllSorted(coll1 LIST<ANY>, coll2 LIST<ANY>) - returns whether or not all of the given values in the second LIST<ANY> exist in an already sorted collection (using a binary search).

Signature

apoc.coll.containsAllSorted(coll :: LIST<ANY>, values :: LIST<ANY>) :: BOOLEAN

Input parameters

Name Type Default

coll

LIST<ANY>

null

values

LIST<ANY>

null

Usage examples

The following checks if a sorted collection contains all the values from another collection:

RETURN apoc.coll.containsAllSorted([1,4,5], [1,4]) AS output;
Table 1. Results
Output

TRUE

This function will not work on unsorted collections, as shown in the example below:

RETURN apoc.coll.containsAllSorted([1,5,4], [1,4]) AS output;
Table 2. Results
Output

FALSE

If we want to find values in an unsorted collection, see apoc.coll.containsAll.