SHARE
TWEET

Untitled

a guest Oct 21st, 2019 83 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**********Bubble Sort***************/
  2.  
  3. function bubbleSort(arr){
  4.   for(let i=0;i<=arr.length;i++){
  5.     for(let j=0;j<=arr.length-i-1;j++){
  6.       if(arr[j]>arr[j+1]){
  7.         let temp=arr[j];
  8.         arr[j]=arr[j+1];
  9.         arr[j+1]=temp;
  10.       }
  11.     }
  12.   }
  13.   return arr;
  14. }
  15.  
  16. console.log(bubbleSort([5,7,8,22,1,90,55,32,7,9,10]));
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top