[Solved] I want to sort the score in my json file from highest to lowest using java script


Try this

var items= {
  "people": [
    {
      "name": "Person A",
      "score": 100
    },
    {
      "name": "Person B",
      "score": 101
    },
    {
      "name": "Person C",
      "score": 100000
    },
    {
      "name": "Person D",
      "score": 555
    }
  ]
};

items.people.sort(function(a, b){
   return a.score - b.score;
});
console.log(items);

it works as expected!

0

solved I want to sort the score in my json file from highest to lowest using java script