Array Sort

Result

To Visualize: Copy code and test Click Here

Code


      let data = [40,30,12,25,54,96,5,8,1];

      for(let i=0; i<data.length;i++){
        for(let j=0;j<data.length;j++){
          if(data[j]>data[j+1]){
            let temp=data[j];
            data[j]=data[j+1];
            data[j+1]=temp;
          }
        }
      }
      console.log(data)