apoc.coll.containsAllSorted

Function APOC Core

apoc.coll.containsAllSorted(coll, value) optimized contains-all on a sorted list operation (Collections.binarySearch) (returns single row or not)

Signature

apoc.coll.containsAllSorted(coll :: LIST? OF ANY?, values :: LIST? OF ANY?) :: (BOOLEAN?)

Input parameters

Name Type Default

coll

LIST? OF ANY?

null

values

LIST? OF 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.