Last active
June 11, 2020 09:51
-
-
Save galElmalah/9b6c55c50ffcb3f5cb4d9c5ba5cc3c6e to your computer and use it in GitHub Desktop.
bubble sort implementation
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
const bubbleSort = (array, onAction) => { | |
for (let i = 0; i < array.length; i++) { | |
for (let j = 0; j < array.length; j++) { | |
if (array[j] > array[j + 1]) { | |
let tmp = array[j]; | |
array[j] = array[j + 1]; | |
array[j + 1] = tmp; | |
} | |
} | |
} | |
return array; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment