Bubble Sort
```function swap(arr,oldIndex,newIndex){ var temp = arr[oldIndex]; arr[oldIndex]=arr[newIndex]; arr[newIndex]=temp; }
function bubbleSort(arr){ let len= arr.length; let i,j; for(i=0;iarr[j+1]) swap(arr,j,j+1); }
return arr;
}
console.log(bubbleSort([12,-7,2,5,6,8,9,2,-3,-6]));
Log in or sign up for Devpost to join the conversation.