Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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;}
  });
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #sort #object #descending
ADD COMMENT
Topic
Name
6+3 =