Skip to content

Instantly share code, notes, and snippets.

@tarzak
Last active December 31, 2015 22:28
Show Gist options
  • Save tarzak/8053388 to your computer and use it in GitHub Desktop.
Save tarzak/8053388 to your computer and use it in GitHub Desktop.
var arr = [2,5,1,0]
addVar = 0,
n = arr.length,
i = 0, j = 0;
for (i = 1; i < n; i++)
for(j = 0; j < n - i; j++)
if (arr[j]>arr[j+1]) {
addVar=arr[j+1]
arr[j+1]=arr[j];
arr[j]=addVar;
}
console.log(arr);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment