Sort query in Java

How can I write the below sort query in java -

"sort": [
  {
    "fieldName1": {
      "order": "desc"
    },
    "fieldName2": {
      "order": "desc"
    }
  }
]

I can do that if the query like -

"sort": [
  {
    "fieldName1": {
      "order": "desc"
    }
  },
  {
    "fieldName2": {
      "order": "desc"
    }
  }
]

but I need the first one.
So is there any way to do that, can anyone suggest please

The first example looks invalid to me. Does that actually work? Where have you seen this type of syntax? What is it you are looking to achieve that the second example does not do?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.