1
votes

I want sort a result, but arango ignore my aql-request.

My Query as example:


 FOR d IN system_menu 
    SORT d.Lvl DESC 
    SORT d.Submenu[*].Lvl DESC
 RETURN d

d.Lvl is a INT-Value. How I can sort a array of documents in a document?

my document:


{
  "System": {},
  "Controller": "reports",
  "Show": true,
  "Icon": "mdi-newspaper",
  "Lvl": 3,
  "Title": {
    "DEde": "Berichte",
    "Universal": "Reports"
  },
  "Submenu": [
    {
      "Title": {
        "DEde": "Tätigkeitsberichte",
        "Universal": "Activity reports"
      },
      "Controller": "activity-reports",
      "Tabmenu": "",
      "Filter": "",
      "Lvl": 2,
      "Show": true,
      "Hrule": false
    },
    {
      "Title": {
        "DEde": "Behördenbericht",
        "Universal": "Authority reports"
      },
      "Controller": "request-data-subject",
      "Tabmenu": "",
      "Filter": "",
      "Lvl": 1,
      "Show": true,
      "Hrule": false
    },
    {
      "Title": {
        "DEde": "Auskunftsersuchen",
        "Universal": "Request from a data subject"
      },
      "Controller": "request-data-subject",
      "Tabmenu": "",
      "Filter": "",
      "Lvl": 3,
      "Show": true,
      "Hrule": false
    }
  ]
}

The sorting does not work! How I sort all my documents per INT from 1...100?

1

1 Answers

1
votes

To sort an inner array, you can use an inner loop, e.g.

FOR d IN system_menu 
  SORT d.Lvl DESC 
  LET submenus = (
    FOR s IN d.Submenu
      SORT s.Lvl DESC
      RETURN s
  )
  RETURN MERGE(d, { Submenu: submenus })