SHARE
TWEET

Untitled

a guest Oct 21st, 2019 73 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function selectionSort(arr){
  2.   for(let i=0;i<arr.length;i++){
  3.     let lowest=i;
  4.     for(let j=i+1;j<arr.length;j++){
  5.       if(arr[j]<arr[lowest]){
  6.         lowest=j;
  7.       }
  8.     }
  9.     let temp=arr[i];
  10.     arr[i]=arr[lowest];
  11.     arr[lowest]=temp;
  12.   }
  13.   return arr;
  14. }
  15.  
  16. console.log(selectionSort([9,3,111,44,2,88,9,4,3,11,2222,90]));
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