How to sort a nested array of objects in karate framework

First need to sort array accountPeriodDetails by accountSystemID, and for each accountSystemID need to sort the array monthlySummary by paymentReportDate

``
`*def response =
'''
{
  "organization": {
    "accountPeriodDetails": [
      {
        "summaryPeriod": "P25M",
        "accountSystemID": "2",
        "tokenizedAccountNumber": "1X68MG14Z7Y5POID",
        "monthlySummary": [
          {
            "paymentReportDate": "2023-09-17",
            "accountTypeCode": "3",
            "currentCreditLineAmount": null,
            "mostRecentPaymentAmount": 7000,
            "currentBalanceAmount": 63198,
            "scheduledPaymentAmount": 0,
            "newChargesAmount": null,
            "totalPastDueAmount": 0
          },
          {
            "paymentReportDate": "2023-08-17",
            "accountTypeCode": "3",
            "currentCreditLineAmount": null,
            "mostRecentPaymentAmount": 10000,
            "currentBalanceAmount": 56522,
            "scheduledPaymentAmount": 0,
            "newChargesAmount": null,
            "totalPastDueAmount": 0
          }
        ]
      },
      {
        "summaryPeriod": "P25M",
        "accountSystemID": "3",
        "tokenizedAccountNumber": "MP3GOU0VQC4V5QQ0Z9GZVQUZNKH",
        "monthlySummary": [
          {
            "paymentReportDate": "2024-10-31",
            "accountTypeCode": "2",
            "currentCreditLineAmount": 100000,
            "mostRecentPaymentAmount": 100,
            "currentBalanceAmount": 76035,
            "scheduledPaymentAmount": null,
            "newChargesAmount": null,
            "totalPastDueAmount": 0
          },
          {
            "paymentReportDate": "2024-04-30",
            "accountTypeCode": "2",
            "currentCreditLineAmount": 100000,
            "mostRecentPaymentAmount": 432,
            "currentBalanceAmount": 40135,
            "scheduledPaymentAmount": null,
            "newChargesAmount": null,
            "totalPastDueAmount": 0
          }
        ]
      }
    ]
  }
}
  • def accountPeriodDetails = response1.organization.sbfeInformation.accountPeriodDetails
  • print accountPeriodDetails
  • def sorted1 = karate.sort(accountPeriodDetails, x => x.accountSystemID)
  • print sorted1`

I have tried to sort using karate.sort(accountPeriodDetails, x => x.accountSystemID), getting error
<eval>:1:36 Expected ,** but found =>**
karate.sort(accountPeriodDetails, x => x.accountSystemID)

Any javascript function solution will also be helpful