Buble Sort
123456789101112131415
const numbers = [3,11,2,5,3,9,7,5,3];
const bubbleSort = arr => {
for(let i=0; i<arr.length; i++) {
for(let j=0; j<arr.length-i; j++) {
if(arr[j] > arr[j+1]) {
[ arr[j], arr[j+1] ] = [ arr[j+1], arr[j] ];
}
}
}
}
bubbleSort(numbers);
console.log(numbers);
JavaScript
INFO