基于neo4j中的收集值进行排序

wlzqhblo  于 2022-11-29  发布在  其他
关注(0)|答案(1)|浏览(146)

我有这个查询MATCH (r:Class {Name: 'A'})-[perm]->(res:source) RETURN res.Name AS resource, collect(type(perm)) AS permission ORDER BY resource
它返回如下响应

"AB sources",
      [
        "D",
        "C",
        "A",
        "B"
      ]

我想要的是这个D C A B应该像A B C D那样排序
我试着把订单放在烫发旁边,但那会出错。我怎么能做到呢?

z2acfund

z2acfund1#

您必须使用APOC库对集合进行排序:

MATCH (r:Class {Name: 'A'})-[perm]->(res:source) 
WITH res.Name AS resource, collect(type(perm)) AS permission
RETURN resource, apoc.coll.sort(permission) AS permission
ORDER BY resource

相关问题