Untitled
unknown
plain_text
a month ago
339 B
2
Indexable
Never
const bubblesort = (arr) => { const size = arr.length for( var i = 0 ; i < size-1; i ++ ){ for( var j = 0; j < size - i - 1; j++) { if ( arr[j] > arr[j + 1]){ var temp = arr[j] ; arr[j] = arr[j+1]; arr[j+1] = temp; } } } } const a = [10,6,7,5,8,4,2,3,1] bubblesort(a) console.log(a)
Leave a Comment