descending order in objects in js code example
Example 1: descending order in objects in js
starWarsPeople.map(e=>{
return e
}).sort((a,b)=> b.height - a.height);
Example 2: javascript sort object by value descending
javascript sort object by value descending
starWarsPeople.map(e=>{
return e
}).sort((a,b)=>{
if (a.height-b.height>1) {return -1;}
else if (a.height-b.height<1) {return 1;}
else {return 0;}
});