Created
July 12, 2020 07:31
-
-
Save KR1470R/b27ca2739987431d77f7d391c1c71b13 to your computer and use it in GitHub Desktop.
Revisions
-
KR1470R created this gist
Jul 12, 2020 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ let arrJertva = [5,3,1,2] let bubble_sort = arr=>{ for (let i=1,n=arr.length;i<n;i++) {//make bubble for (let j=1;j<n;j++) { //iterate every element in bubble if (arr[j] < arr[j-1]) { [arr[j],arr[j-1]] = [arr[j-1],arr[j]] // swaping elements if they equally of condition } } } } bubble_sort(arrJertva) console.log(arrJertva)