Here is an array that I need help with:
"data": {
"risks": [
{
"id": "22",
"name": true,
"surname": 0.5,
"age": 0.75,
"heigth": 50,
"num1": [],
"num2": []
},
{
"id": "55",
"name": true,
"surname": 0.5,
"age": 0.75,
"heigth": 50,
"num1": [],
"num2": []
},
{
"id": "33",
"name": true,
"surname": 0.5,
"age": 0.75,
"heigth": 50,
"num1": [1,2,3,4,5],
"num2": [4,5,6,9]
}
]}
I'm looking to sort the array in a way that objects with either empty num1 or num2 are placed at the end of the array. I attempted to do this using the code below, but it didn't achieve the desired result.
array.sort((x, y) => !!y.num1.length ==0- !!x.num1.length ==0|| !!y.num2.length ==0- !!x.num2.length ==0);