This is my code I have successfully sorted and got my final result to be what I wanted. Now I want to also sort so that the object name that contains the key word "newitem" will always get sorted to the bottom.
    var testgogo = {
      "newitemwrewt": {
        "brand": {
          "gdhshd": true
        },
        "stock": 2,
        "sold": 3
      },
      "other": {
        "brand": {
          "gdhshd": true
        },
        "stock": 2,
        "sold": 3
      },
      "newitemncnc": {
        "brand": {
          "gdhshd": true
        },
        "stock": 2,
        "sold": 3
      },
    };
    finalresult = Object
      .keys(testgogo)
      .sort(
        (a, b) =>
        (testgogo[a].stock !== undefined) - (testgogo[b].stock !== undefined) 
 || testgogo[a].stock - testgogo[b].stock 
|| testgogo[b].sold - testgogo[a].sold )[0];
    console.log(finalresult);
Thanks for any help
 
     
    