I have a JSON URL (https://api.rawg.io/api/games?page=3), and I'm trying to make a appear the name, picture, the slug and the platforms on my front page. I have a idea like sort the most played games and push there id's in a array. But I don't know how I can first sort their number of players and then conserve their id's in an array.
code:
let array = ['']
function sort(x){
    var swapped = true;
    while(swapped){
        swapped = false;
        for (let i = 0; i<x.length;i++){
            if (x[i] > x[i+1]){
                let newnmb = x[i+1];
                x[i+1] = x[i];
                x[i] = newnmb;
                swapped = true;
            }
        }
    }
}
for(page=1;page<=15;page++){
    fetch('https://api.rawg.io/api/games?page='+page)
    .then(response => {
      return response.json()
    })
    .then(data => {
        let i = 0
        while(data.results[i]){ 
            if(typeof data.results[i].added_by_status.playing == 'undefined'){
            }
            else{
                array.push(data.results[i].added_by_status.playing);
            }
            i++
          }
          sort(array)
    })
}
 
     
     
    