My response body looks like this (I'm only showing part of it, in fact it consists of more than 5k id values). I need to check if the ascending sort by key is correct updatedBy.name . But when I encounter a capital letter my test fails.
{
    "data": [
        {
            "id": 1117,
            "acceptance": {
                "externalId": "33232"
            },
            "statusIdFrom": {
                "id": 1,
                "name": "Create"
            },
            "statusIdTo": {
                "id": 1,
                "name": "Create"
            },
            "createdAt": "2021-11-26T06:20:08.717Z",
            "updatedBy": {
                "id": 15,
                "name": "fabric",
                "fullname": "fabric",
                "departmentId": 1
            }
        },
        {
            "id": 1118,
            "acceptance": {
                "externalId": "33234"
            },
            "statusIdFrom": {
                "id": 1,
                "name": "Create"
            },
            "statusIdTo": {
                "id": 1,
                "name": "Create"
            },
            "createdAt": "2021-11-26T07:57:34.108Z",
            "updatedBy": {
                "id": 15,
                "name": "production",
                "fullname": "production",
                "departmentId": 1
            }
        },
        {
            "id": 1119,
            "acceptance": {
                "externalId": "33236"
            },
            "statusIdFrom": {
                "id": 1,
                "name": "Create"
            },
            "statusIdTo": {
                "id": 11,
                "name": "Delete"
            },
            "createdAt": "2021-11-26T07:57:35.238Z",
            "updatedBy": {
                "id": 15,
                "name": "warehouse",
                "fullname": "warehouse",
                "departmentId": 1
            }
        }
    ],
    "quantity": 5449
}
This check works until it encounters a capital letter in the name
let resp = pm.response.json();
console.log(resp.data);
var _ = require('lodash');
let expectedSortedOrder = _.orderBy(resp.data, ['updatedBy.name'],['asc']);
console.log(expectedSortedOrder);
    
pm.test('sort column', () => {
    pm.expect(resp.data).to.eql(expectedSortedOrder);
});
I tried using toLowerCase, but with it I manage to convert only a specific key number, and not the entire body of the response. And it won't help when checking sorting.
I tried this option, but I came across the fact that my test crashes when it sees empty "null" values
pm.test("sort column", () => {
    const response = pm.response.json();
    // Extract all ids in an array
    const art = response.data.map(item => item.updatedBy.name);
    
    // Check that all are ascending
    function isAscending(a) {
        return a.every((x, i) => {
            return i === 0 || x >= a[i-1];
        });
    }
    pm.expect(isAscending(art)).to.be.true;
});
I will be grateful for any help. Thanks
 
    