I have this code where a response array will be sorted out by name.
var responseArray = pm.response.json();
var _ = require('lodash');
let expSortedOrder = _.sortBy(responseArray.results, (results) => {return _.lowerCase(results.name)});
console.log(expSortedOrder);
pm.expect(responseArray.results).to.eql(expSortedOrder);
I am having issue with the way this sorts the name values with space and numbers. API response sorted the name with space first then number:
[
{
"id": 123,
"name": "test name"
},
{
"id": 456,
"name": "test.name"
},
{
"id": 789,
"name": "Test1 Name"
}
]
Test script using loadash sorted the name with space first then number:
[
{
"id": 789,
"name": "Test1 Name"
},
{
"id": 123,
"name": "test name"
},
{
"id": 456,
"name": "test.name"
}
]
Is there a way for me to change what the sort should prioritize?