score:1

Accepted answer

In line#23 mentioned in codepen pass the resolved data to sort_by function

data = sort_by("A", data);  

Now sort_by funntion will be

let sort_by = function(val, playerData){
    console.log(`Passed in value is: ${val}`);
    if(playerData) {
      return sortLogic(val, playerData)
    } else {
      player_data.then(function(data){
        return sortLogic(val, data); 
      });
    }
};

let sortLogic = function (val, data) {
  let new_data = data.slice().sort((a,b) => d3.descending(+a[val], +b[val]));
  console.log(new_data);
  return new_data;
}

Related Query

More Query from same tag