diff --git a/.all-contributorsrc b/.all-contributorsrc index 4342ac5d..0b314087 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -329,6 +329,16 @@ "code" ] } + ], + { + "login": "RrennM", + "name": "RrennM", + "avatar_url": "https://avatars2.githubusercontent.com/u/27599411?s=400&u=773dbb8a4f877cf06770cbd39e4ddeeafeedcbdd&v=4", + "profile": "https://github.com/RrennM", + "contributions": [ + "code" + ] + } ], "commitConvention": "none" } diff --git a/day31/JavaScript/bubblesort.js b/day31/JavaScript/bubblesort.js index e69de29b..eefb5688 100644 --- a/day31/JavaScript/bubblesort.js +++ b/day31/JavaScript/bubblesort.js @@ -0,0 +1,18 @@ +/** + * @author: RrennM + * @date: Oct 28, 2020 +**/ + +let bubbleSort = (arr) => { + for(i = 0; i < arr.length; i++) { + for(j = 0; j < arr.length; j++) { + if (arr[j] > arr[j+1]) { + arr.splice(j+2, 0, arr[j]) + arr.splice(j, 1) + } + } + } + return arr; +} + +bubbleSort([1, 8, 3, 2, 9, 5, 4]) \ No newline at end of file