Guest User

Untitled

a guest
Apr 20th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. function bubbleSort(arr) {
  2. for (let i = 0; i < arr.length; i++) {
  3. for (let j = i + 1; j < arr.length; j++) {
  4. if (arr[i] > arr[j]) {
  5. [ arr[i], arr[j] ] = [ arr[j], arr[i] ];
  6. }
  7. }
  8. }
  9.  
  10. return arr;
  11. }
  12.  
  13. console.log(bubbleSort([12,12,33,4,15, 14 ,6, 8,7,28, 19, 30, 40]))
Add Comment
Please, Sign In to add comment