Ranking user score

Ranking user score

Hi,

I have an array which consists of 600 records in the format of:

  1. John, Nikhil C.,467,Cule, Mac A.,341,Pat, Ryan,465
  2.   [
          [0...99]: [
             [0...9]: [
                0: "John, Nikhil C.",
                1: "467",
                2: "Cule, Mac A.",
                3: "341",
                4: "Pat, Ryan",
                5: "465",
              
             ],


I am trying to create a ranking model for the above, in the sense the John has rank1, pat as rank 2, john, cule as rank3 and push it back to the array.

Below is the code which i have tried:

  1.  var items = data.d.results;
  2. if(items.length > 0){
    for (i = 0; i < items.length; i++) {
     playerDetails.push( items[i].Title , items[i].Points );   
     }
     var scores = playerDetails.map(function(d) { return d[1]; }).sort().reverse();
       console.log(playerDetails);


The above code is not sorting the data.  Is this possible in jQuery? I am looking at getting result as:

  1. John, Nikhil C.,467,1,Pat, Ryan,465,2,Cule, Mac A.,341,3

The existing array playerDetails should add the rank based on the scores " 467, 465, 341". If 2 person have same score, then the rank should be same for them.


How to achieve it? Thanks