Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function bubbleSort(arr) {
- for (let i = 0; i < arr.length; i++) {
- for (let j = i + 1; j < arr.length; j++) {
- if (arr[i] > arr[j]) {
- [ arr[i], arr[j] ] = [ arr[j], arr[i] ];
- }
- }
- }
- return arr;
- }
- console.log(bubbleSort([12,12,33,4,15, 14 ,6, 8,7,28, 19, 30, 40]))
Add Comment
Please, Sign In to add comment