JSFiddle - React, Tailwind, and code Playground
by Arvind Pal
JavaScript
let arr = [23,21, 56,9];
let c=0;
function bubbleSort(arr){
for(let i=0; i<arr.length; i++){
for(j=0;j<arr.length; j++){
if(arr[j]>arr[j+1]){
let temp=arr[j];
arr[j] = arr[j+1];
arr[j+1] = temp;
}
}
console.log(++c, arr)
}
}
bubbleSort(arr)
//console.log(arr)