Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function selectionSort(arr){
- for(let i=0;i<arr.length;i++){
- let lowest=i;
- for(let j=i+1;j<arr.length;j++){
- if(arr[j]<arr[lowest]){
- lowest=j;
- }
- }
- let temp=arr[i];
- arr[i]=arr[lowest];
- arr[lowest]=temp;
- }
- return arr;
- }
- console.log(selectionSort([9,3,111,44,2,88,9,4,3,11,2222,90]));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement