apoc.map.sortedProperties

Details

Syntax

apoc.map.sortedProperties(map [, ignoreCase ])

Description

Returns a LIST<ANY> of key/value pairs. The pairs are sorted by alphabetically by key, with optional case sensitivity.

Arguments

Name

Type

Description

map

MAP

The map to extract the properties from.

ignoreCase

BOOLEAN

Whether or not to take the case into account when sorting. The default is: true.

Returns

LIST<ANY>

Usage Examples

The following examples return a list of key/value pairs with each pair sorted by alphabetically their key using both APOC and Cypher:

apoc.map.sortedProperties
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN apoc.map.sortedProperties(map) AS output
Using Cypher’s COLLECT subquery
WITH {name:"Cristiano Ronaldo",country:"Portugal",dob:date("1985-02-05")} AS map
RETURN COLLECT {
    UNWIND keys(map) AS key
    RETURN [key, map[key]] ORDER BY key
} AS output
Results
output

[["country","Portugal"],["dob","1985-02-05"],["name","Cristiano Ronaldo"]]