Skip to content

Instantly share code, notes, and snippets.

@lukeo357
Created April 18, 2015 12:26
Show Gist options
  • Save lukeo357/637f82b0718c5e06e49f to your computer and use it in GitHub Desktop.
Save lukeo357/637f82b0718c5e06e49f to your computer and use it in GitHub Desktop.
JSV JSV // source http://jsbin.com/cotive
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="JSV">
<meta charset="utf-8">
<title>JSV</title>
</head>
<body>
<script id="jsbin-javascript">
//bubbleSort
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10];
function bubbleSort(data) {
for(var k = 0; k <= data.length/2; k++) {
for(var i = 0; i < data.length - k; i++) {
if(data[i] > data[i + 1]) {
var temp = data[i];
data[i] = data[i + 1];
data[i + 1] = temp;
}
}
}
return data;
}
bubbleSort(datArray);
console.log(datArray);
</script>
<script id="jsbin-source-javascript" type="text/javascript">
//bubbleSort
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10];
function bubbleSort(data) {
for(var k = 0; k <= data.length/2; k++) {
for(var i = 0; i < data.length - k; i++) {
if(data[i] > data[i + 1]) {
var temp = data[i];
data[i] = data[i + 1];
data[i + 1] = temp;
}
}
}
return data;
}
bubbleSort(datArray);
console.log(datArray);
</script></body>
</html>
//bubbleSort
var datArray = [3,4,6,2,1,5,8,7,12,9,11,10];
function bubbleSort(data) {
for(var k = 0; k <= data.length/2; k++) {
for(var i = 0; i < data.length - k; i++) {
if(data[i] > data[i + 1]) {
var temp = data[i];
data[i] = data[i + 1];
data[i + 1] = temp;
}
}
}
return data;
}
bubbleSort(datArray);
console.log(datArray);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment