Skip to content

Commit

Permalink
Sort an array without using in build functions
Browse files Browse the repository at this point in the history
Code to sort the given array without using Inbuilt functions
  • Loading branch information
Arunkumar1712 authored Jan 4, 2024
1 parent 212817a commit 75568e9
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions sortarray.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
var a=[1,3,2,7,4,10,9];
for(var i=0;i<a.length;i++){
var a1=a[i];
var a2=a[i+1];
var dif = a1-a2;
if(dif>0){
a[i]=a[i+1];
a[i+1]=a1;
}
}
console.log(a);

0 comments on commit 75568e9

Please sign in to comment.