Added selection sort algorithm in javascript (#33)

pull/39/head
Roshan Kumar 2021-01-28 01:36:56 +05:30 committed by GitHub
parent 6c8e1697ea
commit 4c9fab8025
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,15 @@
let sort = [12,6,3,88,1,4,8]
for(let i=0; i<sort.length; i++){
for(let j=0; j<sort.length; j++){
// comparing array elements
if(sort[j]>sort[i]){
//swaping elements
let temp = sort[i];
sort[i]=sort[j];
sort[j]= temp;
}
}
}
console.log(sort)