Quick actions

cmd+k|ctrl+k

Navigation

Languages

Bubble Sort

Snippet info

Language

JavaScript

Visibility

public

Author

saurabhtiwari75844

Created

2023-03-16T11:40:06.157377Z

Updated

2023-03-16T11:40:06.157377Z


const numbers =[99, 44,6,2,1,5,63,87,283,4,0];
function bubbleSort(array) {
    const length= array.length;
    
    for(let i=0; i<length; i++) {
        for(let j=0; j < length; j++) {
            if(array[j]>array[j+1]) {
                let temp = array[j];
                array[j]= array[j+1];
                array[j+1]= temp;
            }
        }
    }
}

console.log(numbers);
INFO