Created
April 12, 2017 19:43
-
-
Save a-eid/2a7d7d597d4300c8075d543dc239f084 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function bubble_sort(arr){ | |
for(let i = 0 , n = arr.length ; i < n - 1 ; n -= 1){ | |
for(let ii = i , j = i + 1 ; j < n ; j += 1 , ii += 1){ | |
if(arr[ii] > arr[j]){ | |
let temp = arr[ii] | |
arr[ii] = arr[j] | |
arr[j] = temp | |
} | |
} | |
} | |
return arr | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment