I'm using the sort array prototype function on my array of objects-- sorting by the 'min' key
function setStatesOrder(stateOrderArr){
return stateOrderArr.sort((x,y) => x.min - y.min);
}
But right now I want to keep the first object in my array of objects out of the sort. It has a key of "state" and value of "U.S." so I was trying to exclude this object by that but it's not working:
function setStatesOrder(stateOrderArr){
return stateOrderArr.sort((x,y) => {if(x.state !=="U.S."){x.min - y.min}});
}
stateOrderArr = [
{state: "U.S.", max: 1, min: -14, stateID: "US", final: 0.3},
{state: "Ohio", max: 5, min: -2, stateID: "OH", final: 5},
{state: "Georgia", max: 4, min: -5, stateID: "GA", final: -5},
{state: "Arizona", max: -1.5, min: -2, stateID: "AZ", final: -2}....]